Is it possible to create trigger on all tables by modifying declarative_base? #1478
-
I want to add Trigger will look like this:
Because the column
I made sure the above works, the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Are you looking for trigger DDL() to be added to your model as you have above, or within your actual alembic migrations? There are different approaches you'd be taking. if you are looking for alembic migrations to automatically include additional steps that aren't supported by autogenerate you'd be using process_revision_directives and you'd be rendering additional ExecuteSQLOp directives into the structure. |
Beta Was this translation helpful? Give feedback.
SQLAlchemy has no notion of a "trigger" object directly, and the feature you are using with Base is specific to ORM mapped attributes that map to database columns. So there is no facility in Alembic autogenerate to read records from a Base class with a mapped table and then generate "triggers".
alembic_utils does have an explicit "trigger" notion but I am not familiar with the extent to which it has produced an "autogenerate" feature which would work from some metadata-level directives to produce them. if it did, you still could not use
Base.column = Column()
because that feature only applies to mapped columns; you instead woul…