且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Alembic util命令错误找不到标识符

更新时间:2023-01-22 20:30:15

Alembic将版本历史记录存储在数据库中。因此,它使用存储在数据库中的值来搜索修订。我的个人数据库的版本号存储在表 alembic_version 中:

Alembic stores the version history in your database. Hence it is using the value stored in your database to search for the revision. The version number for my personal database is stored in the table alembic_version:

mysql> SELECT * FROM alembic_version;
+-------------+
| version_num |
+-------------+
| c8ad125e063 |
+-------------+
1 row in set (0.00 sec)

提示:如果它是基于SQL的数据库来查看表,请使用命令 SHOW TABLES

Hint: Use the command SHOW TABLES if it's a SQL based database to see the tables.

要解决您的问题,只需使用以下命令:

To solve your problem simply use the command:

DROP TABLE alembic_version;

或者与数据库版本表的名称无关。
然后,您需要使用以下命令重新初始化迁移文件夹:

Or whatever the name of database version table is. And then you need to re-init the migration folder using the command:

python manage.py db init

然后创建新迁移:

python manage.py db migrate

然后您应该很好在alembic中进行工作迁移。

And then you should be good to go with working migrations in alembic.