Alembic with default schema + other schemas always recreates table when just adding a column #1475
Unanswered
NicolasDijols
asked this question in
Usage Questions
Replies: 2 comments 2 replies
-
I have a similar problem. Did you find a solution? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi, I believe that the include_name you are using is telling alembic to ignore any scheme, so the database is always reflected as empty. From your description shouldn't you tell alembic to include the public (probably reflected with name |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, i'm very new to Alembic and i'm trying to test it with a very simple project.
Describe the bug
My database(Postgis) has 3 schemas: public, topology and tiger.
My own tables are in the public schema.
Running a first migration that adds a table 'users' is going well but when i try to make a new migration to add a single column, the migration script creates the whole users table again (with the new column) instead of just add the column to the users table.
I found theses issues: #1282 and #1416. Mine seems to be a combination of both.
Following answers from these issues, I've added this in my env.py:
This is ok for not touching topology and tiger schemas when creating a new migration, but as i said the users table is recreated entirely.
If i remove the include_schemas and include_name arguments when calling context.configure, now the column is added correctly, without recreating the whole users table, but the migration script removes all tables in topology and tiger schemas.
Expected behavior
I would like to be able to have non default schema alongside the default one, add tables into the default schema without removing any tables from other schemas and when add or remove column from my own table, not recreate the whole table each time.
To Reproduce
The env.py is the one by default with these additions:
After running
alembic revision --autogenerate -m "Initial migration"
Uncomment the phone_number field in User from models.py
After running
alembic revision --autogenerate -m "add phone number"
Error
Not an error per se but compare should not detect these when autogenerate a second migration
Versions.
Additional context
Have a nice day!
Beta Was this translation helpful? Give feedback.
All reactions