Frage

In sqlalchemy-migrate repos, we can place .sql files instead of .py files under versions folder for upgrading/downgrading database schema.

001_mysql_downgrade.sql
001_mysql_upgrade.sql

Is the same feature exist in alembic? If yes can someone plz explain how to do?

Thanks

War es hilfreich?

Lösung

you could call upon those files in your migration .py files, inside your upgrade() and downgrade() callables. You can customize how those callables render by editing your script.py.mako file.

However, for the .py file to not be there at all, you'd need to override ScriptDirectory and Script right now, unless we made more of a hook to implement extensions like this. Overriding those classes is possible but would likely require monkeypatching at the moment. It's certainly something Alembic could support.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top