运行 迁移时检测到表,但未在数据库中创建

Tables are detected when running migration, but aren't created in database

我 运行 为 cookiecutter Flask 应用创建 SQLite table 的迁移。虽然数据库文件存在并且我可以打开它,但我看不到 tables。当我尝试创建用户时出现 "no such table" 错误。为什么我 运行 迁移后 table 不存在?如何使用 tables?

$ python manage.py db migrate
INFO  [alembic.migration] Context impl SQLiteImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.
INFO  [alembic.autogenerate.compare] Detected added table 'tags'
INFO  [alembic.autogenerate.compare] Detected added table 'users'
INFO  [alembic.autogenerate.compare] Detected added table 'posts'
INFO  [alembic.autogenerate.compare] Detected added table 'tags_posts'
Generating C:\envs\r2\myflaskapp\migrations\versions\....
sqlalchemy.exc.OperationalError OperationalError: (OperationalError) no such table:

您只生成了迁移,还需要应用它。请务必通读生成的迁移文件以确保它在 运行 之前是正确的。

python manage.py db upgrade

Alembic (the migration engine) and Flask-Migrate(管理命令)的文档中描述了应用生成的迁移。