Support for auto-generated SQL migrations in online mode #1545
Replies: 1 comment 5 replies
-
you can put raw SQL in a migration file like this: def upgrade():
op.get_bind().exec_driver_sql("""
CREATE TABLE ....
""") however, the ask here seems to be that autogenerate would run normally, and create migration files, but instead of using alembic migration ops, would create a new .sql file with some migration that reads it. We have had requests for migration files placed in .sql mode, for which it's easy enough to create migration files that consume the SQL files, but for autogenerate to create these files in the first place which are generated in any case from alembic's own operators, I dont see the point of that.
absolutely, which is what |
Beta Was this translation helpful? Give feedback.
-
Describe the use case
Not everyone wants to use an ORM to add and edit database migrations. For enterprise graded production databases, reading raw SQL might even be more useful for database administrators. Alembic does currently not support that, other then the offline mode.
Databases / Backends / Drivers targeted
To start with, PostgreSQL
Example Use
After configuration, I foresee something like the following steps.
alembic revision --autogenerate --sql -m "Added account table"
, which will create one more SQL file containing the code for upgrading and downgrading the database. Similar to the regular migration files, this will also hold metadata.alembic upgrade head
, which will take the files into account.Beta Was this translation helpful? Give feedback.
All reactions