If someone new come to the project and they use  db.create_all() or some 
script to create a fresh new database with declared models. There is no 
alembic_version table and he/she will run into problems when doing the 
upgrade. Is there something in alembic to support it? I have been poking 
around and came up with the following:

 alembic_cfg = Config("alembic.ini")
 context = MigrationContext.configure(db.engine.connect())
 current_rev = context.get_current_revision()
 context._ensure_version_table()

 script = ScriptDirectory.from_config(alembic_cfg)
 head_revision = script.get_current_head()
 context.stamp(script, head_revision)

 command.downgrade(alembic_cfg, "base")

However, it works with file based sqlite db but no in memory one: 
Error: Destination base is not a valid downgrade target from current head(s)

It seems the migrationcontext use different from the one I generated and 
the one used in the alembic, so the current revision was empty when I do 
the downgrade (just for. Not sure why file based sqlite works.


Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to