Alembic not working with existing database built with SQLModel #1046
Unanswered
liberty-rising
asked this question in
Usage Questions
Replies: 3 comments 9 replies
-
Hi, Please ensure that in the env you are importing all the modules that define tables in the metadata and that the connection is to rhe correct database/schema. |
Beta Was this translation helpful? Give feedback.
7 replies
-
I have same problem:((( |
Beta Was this translation helpful? Give feedback.
0 replies
-
any updates on that ? i was struggling for a few days on this and it seems like the problem is just ignored lol |
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
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
I have an existing database that I am trying to connect alembic to. Running
py -m alembic revision --autogenerate -m "Initial Migration"
generates an alembic version that contains the creation of each table in my database. I cannot runalembic upgrade
in this case since the database already contains the tables to be created, along with data already existing within those tables.Therefore I tried creating a temporary empty database and running the migration there. Upon doing so, the temporary database populated with the necessary values. I then switched the connection string within the
alembic.ini
file to point to the production database, ranpy -m alembic stamp head"
and thenpy -m alembic revision --autogenerate -m "Second Migration"
. This command once again creates a version which creates all of my existing tables.Expected behavior
Upon use of
py -m alembic revision --autogenerate -m "Initial Migration"
orpy -m alembic revision --autogenerate -m "Second Migration"
, alembic should generate a version that is empty since nothing was changed in the existing code.To Reproduce
alembic.ini
script.py.mako
env.py
Error
Versions.
Additional context
Have a nice day!
Beta Was this translation helpful? Give feedback.
All reactions