CreateColumnCommentOp and postgresql_using Autogeneration in Alembic #1595
Replies: 2 comments 2 replies
-
column comments are part of the if I understand USING correctly, this is a directive given at ALTER COLUMN time which indicates what transformation should be applied to existing values in the column. This expression is not part of the SQLAlchemy you can if you wanted add your own "postgresql_using" note to the Column.info dictionary and consume it during autogenerate using a rewriter to help render this from your models. |
Beta Was this translation helpful? Give feedback.
-
I understand column comments are part of the when it comes to type change in column, alembic can auto generate such scripts,
it will fail when applied in postgresql directly. One should use
if this is the only case that I need to handle in USING, maybe I can just use rewriter to handle this and do not need to add something in Column.info? and I have another question. When faced with a situation where both the type and the comment of a column are changed, does autogenerate generate a single AlterColumnOp to handle both changes, or does it split them into two separate operations? |
Beta Was this translation helpful? Give feedback.
-
CreateColumnCommentOp
Alembic already has
CreateTableCommentOp
, but there’s no operation for adding or modifying column comments. Would adding aCreateColumnCommentOp
be a good idea?My use case involves categorizing schema changes into "safe" (e.g., adding columns, tables, or comments) and "unsafe" (e.g., dropping columns or changing column types). So apparently table comment and column comment should be considered safe but in column we only have
AlterColumnOp
. Maybe I can custom such a operation but I believe it would be nice if alembic will have a build-inCreateColumnCommentOp
likeCreateTableCommentOp
postgresql_using in Autogenerate
When altering column types in PostgreSQL, the USING clause is often required for type casting. Currently, Alembic does not autogenerate the
postgresql_using
parameter, so I need to manually add it to the revision files.Would it be possible for Alembic to autogenerate this when it comes to type change?
Beta Was this translation helpful? Give feedback.
All reactions