server_onupdate ignored when generating migration script #1055
-
Describe the bug Alembic is ignoring server_onupdate column when generating migration file.
The generated migration will be
Expected behavior Expected
To Reproduce No errors generated and producing simply requires generating a migration file and looking at the Versions.
Additional context Have a nice day! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
server_onupdate is a Python behavioral element only and has no effect on DDL, which is the purpose of alembic. how is this affecting your use case? |
Beta Was this translation helpful? Give feedback.
-
Thanks @zzzeek , this was a confusing point since this behaves different than server_default. I reread the documentation and it does say that it does not have an effect on DDL. Out of curiosity, is it possible to create the necessary trigger function to add this functionality? |
Beta Was this translation helpful? Give feedback.
-
triggers are very specific to each database vendor, they are written in a style that is more imperative rather than declarative (meaning, you really have to use the trigger syntax directly to be effective) and they tend to introduce lots of complications to things (changing the behaviors of INSERT/UPDATE/DELETE in many idiosyncratic ways), so SQLAlchemy/ Alembic steers completely clear of having any direct interaction with trigger syntax. however good news is you're on PostgreSQL and there's a great project alembic-utils where someone was nice enough to get into all of that, so perhaps this project can provide some help on adding triggers. |
Beta Was this translation helpful? Give feedback.
server_onupdate is a Python behavioral element only and has no effect on DDL, which is the purpose of alembic. how is this affecting your use case?