Why does alembic put old tables in a new migration? #1451
Unanswered
Johnb6262
asked this question in
Usage Questions
Replies: 1 comment 3 replies
-
Hi, Can you clarify a bit how is your env setup? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am setting up alembic in a new project.
I successfully got the first migration working in my local and aws postgres databases. Added 5 tables.
I then added a new model to the same .py file I had used before and ran the alembic command to make the migration file.
alembic revision --autogenerate -m "Add Message model"
I expected only the new table to show up in the migration file. Instead, the new migration file contains all the old tables and the one new one I added for a total of 6.
Of course, running the "alembic upgrade head" command fails because the old tables are already in my database.
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateTable) relation "module" already exists
What have I misunderstood or done wrong? I expected ONLY the new table to be picked up in the new migration file as with the Django migration tool I'm familiar with...
And - alembic writes ONLY the latest migration file's version number to the database? How do I then track what has or hasn't happened in terms of migrations in that specific database?
Beta Was this translation helpful? Give feedback.
All reactions