How to check or edit the autogenerated migration? #802
Replies: 3 comments 5 replies
-
If you have explicit rules, like all indexes should have postgresql_concurrently, then i would recommend receiving the revision directives using process_revision_directives: https://alembic.sqlalchemy.org/en/latest/api/runtime.html#alembic.runtime.environment.EnvironmentContext.configure.params.process_revision_directives which receives the autogenerated structure, walks through it, and verifies that the expected elements are present. You can likely make this a simpler operation by using an autogenerate rewriter: https://alembic.sqlalchemy.org/en/latest/api/autogenerate.html#fine-grained-autogenerate-generation-with-rewriters , where you would for this example instrument the CreateIndexOp:
|
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for the answer, now the thing is |
Beta Was this translation helpful? Give feedback.
-
we made a special construct for this case specifically, see autocommit_block at https://alembic.sqlalchemy.org/en/latest/api/runtime.html#alembic.runtime.migration.MigrationContext.autocommit_block |
Beta Was this translation helpful? Give feedback.
-
When we autogenerate the migration through alembic, I would like to ensure that the migration file generated passes few checks. For example, if we add an index to a column the autogenerated file should automatically add
postgresql_concurrently=True
to the attribute.Is there any programmatical way to verify the autogenerated migration?
Have a nice day!
Beta Was this translation helpful? Give feedback.
All reactions