alembic util command error can't find identifier

前端 未结 3 455
死守一世寂寞
死守一世寂寞 2021-01-30 06:51

I\'m trying to use alembic to handle local migrations on my project. It worked the first time, but then I needed to delete the folder and restart.(don\'t ask why, I just had to)

3条回答
  •  礼貌的吻别
    2021-01-30 07:18

    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)
    

    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
    

    And then creating a new migration:

    python manage.py db migrate
    

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

提交回复
热议问题