-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Why isn't the audit_table() trigger added to new tables that are created with alembic revision --autogenerate? Am I correct in suspecting that Alembic doesn't support this?
If so, perhaps we could add a section in the documentation about using alembic's rewriter functionality to achieve this instead. This is how I'm currently solving it in my env.py:
from alembic import context
from alembic.autogenerate import rewriter
from alembic.operations import ops
writer = rewriter.Rewriter()
@writer.rewrites(ops.CreateTableOp)
def create_table(context, revision, op):
return [
op,
ops.ExecuteSQLOp("SELECT audit_table('{}');".format(op.table_name)),
]
def run_migrations_online():
context.configure(
process_revision_directives=writer,
...It should be noted that the __versioned__ attribute isn't respected when doing it this way. AFAIK the model isn't available in this context, but perhaps __versioned__ could be passed to the table. Maybe you have some idea on how to achieve this, @kvesteri?
Metadata
Metadata
Assignees
Labels
No labels