alembic autogenerate tries to generate existing tables.

398 views
Skip to first unread message

Johannes Bretscher

unread,
May 5, 2021, 11:22:14 AM5/5/21
to sqlalchemy-alembic

Hello,
I am new to alembic and expect this to have a simple solution, but with my limited knowledge I can't find it.
I have a database, genereted from scratch with sqlalchemy in postgresql. After that I wanted to try the alembic autogenerate tool. I initialize in env.py with exactly the same schema with that the database was just created. Now I get:

jbr@AIRA-207:~/code/database$ alembic -c alembic/alembic.local.ini revision --autogenerate -m "Startup state"
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
/usr/local/lib64/python3.8/site-packages/sqlalchemy/sql/ddl.py:1211: SAWarning: Cannot correctly sort tables; there are unresolvable cycles between tables "application.products, application.versions", which is usually caused by mutually dependent foreign key constraints.  Foreign key constraints involving these tables will not be considered; this warning may raise an error in a future release.
  util.warn(
INFO  [alembic.autogenerate.compare] Detected added table 'application.customers'
INFO  [alembic.autogenerate.compare] Detected added table 'application.documents'
[...]

And so on. All the "added table" do already exist. An "upgrade" of cours fails with a lot of SQL errors, telling me exactly that, that those tables are already existing.
Can you give me a pointer at what I am missing?

Thanks.
Reply all
Reply to author
Forward
0 new messages