op.add_column() and op.drop_column() should check for SchemaType, run through the events for that type, or perhaps just create/drop
See original GitHub issueMigrated issue, originally created by Wichert Akkerman (@wichert)
I have a data model which has a simple enum column:
size_type = schema.Column(
types.Enum('normal', 'plus', name='size_type_type'),
nullable=False, default='normal')
as part of an upgrade routine I need to add that column if it is missing:
alembic.add_column('article_variant',
ArticleVariant.__table__.c['size_type'].copy())
alembic is an operation instance here. This operation breaks due to a missing check if the enum type already exists. The resulting error is:
sqlalchemy.exc.ProgrammingError: (ProgrammingError) type "size_type_type" does not exist
LINE 1: ALTER TABLE article_variant ADD COLUMN size_type size_type_t...
^
'ALTER TABLE article_variant ADD COLUMN size_type size_type_type NOT NULL' {}
Issue Analytics
- State:
- Created 11 years ago
- Reactions:3
- Comments:13 (1 by maintainers)
Top Results From Across the Web
Operation Reference — Alembic 1.9.0 documentation
All directives exist as methods on a class called Operations . When migration scripts are run, this object is made available to the...
Read more >Dropping foreign keys in Alembic downgrade? - Stack Overflow
However I can't figure out how to drop foreign keys from the Alembic Documentation. Downgrade method: def downgrade(): # Drop Indexes op.
Read more >How to use the alembic.op.execute function in alembic - Snyk
To help you get started, we've selected a few alembic.op.execute examples, based on popular ways it is used in public projects.
Read more >ALTER TABLE - Azure Databricks - Microsoft Learn
If you use Unity Catalog you must have MODIFY permission to: ALTER COLUMN; ADD COLUMN; DROP COLUMN; SET TBLPROPERTIES; UNSET TBLPROPERTIES. All ...
Read more >Alembic Documentation - Read the Docs
env.py - This is a Python script that is run whenever the alembic ... DDLEvents.column_reflect() event to detect when a CHAR (or whatever....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Easy workaround:
Looks like this is still a problem