Autogenerated migration misses changes to server_default and onupdate #1204
Unanswered
jankatins
asked this question in
Usage Questions
Replies: 1 comment
-
Hi, That's working as expected. server default are not compared by default. See https://alembic.sqlalchemy.org/en/latest/api/runtime.html#alembic.runtime.environment.EnvironmentContext.configure.params.compare_server_default
not sure what you mean by this. onupdate is related to what sqlalchemy will do when issuing an update https://docs.sqlalchemy.org/en/20/core/metadata.html#sqlalchemy.schema.Column.params.onupdate |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
If a SQLA model was already created and now the server_default
or on_update changes/gets added, there is no migration created.Expected behavior
I expect some alter column statement getting generated.
To Reproduce
before:
Alembic generates a migration for this:
Changing the model to:
and running
alembic revision --autogenerate -m "test2"
will essentially create an empty migration (I have some autogenerated "CREATE SCHEMA IF NOT EXIST ... " in there). If I instead generate a complete new table (by simply changing the name so the old table gets removed and the new one gets created), I get the correct migration:(Update: I also just realized that no trigger is getting created for onupdate :-( Ouupsi, glad that I saw this...)
Error
None :-( Also no warnings relating to this (I've cycles in my tables and also some warnings re "expression-based index" due to a exclusion statement).
Also no warning that onupdate is not working on PG :-(
Versions.
Beta Was this translation helpful? Give feedback.
All reactions