user1592380
user1592380

Reputation: 36215

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

I ran a migration to create the SQLite tables for a cookiecutter Flask app. Although the database file exists and I can open it, I cannot see the tables. When I try to create a user I get a "no such table" error. Why doesn't the table exist even though I ran the migration? How can I use the 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:

Upvotes: 3

Views: 720

Answers (1)

davidism
davidism

Reputation: 127180

You only generated the migration, you need to apply it as well. Be sure to read through the generated migration file to ensure it's correct before running it.

python manage.py db upgrade

Applying generated migrations is described in the docs for both Alembic (the migration engine) and Flask-Migrate (the manage commands).

Upvotes: 2

Related Questions