Closed PJansson closed 7 months ago
I'm reasonably sure I can reproduce the issue you're having, but it's more an issue/side-effect of alembic, i think.
Table autogeneration is handled natively by alembic. you're defining a schema and referencing it with alembic, but natively for tables, alembic requires you set:
context.configure(
connection=connection,
target_metadata=target_metadata,
include_schemas=True
)
In order to track things in anything but the default (public) schema. After that, the table behavior works as expected. I'm guessing this is the same behavior you'd see if you had manually defined the table yourself.
The functions/triggers are getting CREATE OR REPLACE
'd which I believe is unavoidable, and shouldnt result in any issues
Ah yeah, you are correct! I was under the impression that alembic would also handle tracking for everything its able to create, quite weird to have one but the other. Simply including schemas in env.py
did the trick, thank you!
I am testing the following setup:
Then I have set
target_metadata = Base.metadata
andregister_alembic_events()
in my alembic env.py.This works as expected for the first migration but lets say I add a new column to the
user_account
table and autogenerate a new alembic revision it will try create a newuser_account_audit
table and its triggers instead of updating the existing ones. Is there a way to have alembic update the audit table and the corresponding triggers automatically?