add mssql_drop_XYZ flags to autogenerate op.drop_column() based on observation of mssql + known type-specific check constraints, defaults, FKs
See original GitHub issueMigrated issue, originally created by Marek Baczyński (@imbaczek)
DB: SQL Server 2008R2
SQLAlchemy==0.9.3
alembic==0.6.4dev (today’s master and 0.6.3 too)
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('table', sa.Column('col1', sa.Enum('one', 'two', name='ck_col1'), nullable=True))
op.add_column('table', sa.Column('col2', sa.Boolean(name='ck_col2'), nullable=True))
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('table', 'col2')
op.drop_column('table', 'col1')
### end Alembic commands ###
$ alembic downgrade 328
INFO [alembic.migration] Context impl MSSQLImpl.
INFO [alembic.migration] Will assume transactional DDL.
INFO [alembic.migration] Running downgrade 26f5521a70be -> 328b04eddf97, added table table
[...]
File "pymssql.pyx", line 435, in pymssql.Cursor.execute (pymssql.c:6347)
sqlalchemy.exc.OperationalError: (OperationalError) (5074, "The object 'ck_col2' is dependent on column 'col2'.DB-Lib error message 5074, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 4922, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n") 'ALTER TABLE [table] DROP COLUMN col2' {}
(constraint names above are tweaked to increase readability, related to #183)
Attachments: 184.patch
Issue Analytics
- State:
- Created 10 years ago
- Comments:17 (1 by maintainers)
Top Results From Across the Web
Delete Check Constraints - SQL Server
Deleting check constraints removes the limitations on data values that are accepted in the column or columns included in the constraint ...
Read more >How to drop column with constraint? - sql server
First you should drop the problematic DEFAULT constraint , after that you can drop the column alter table tbloffers drop constraint ...
Read more >SQL Injection Cheat Sheet
The SQL Injection Cheat Sheet is the definitive resource for all the technical details about the different variants of the well-known SQLi vulnerability....
Read more >Operation Reference — Alembic 1.9.0 documentation
This so that migration instructions can be given in terms of just the string names and/or flags involved. The exceptions to this rule...
Read more >SQL Examples
Structured data in the relational model means data that can be represented in tables -- rows and columns. Each row in a table...
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
Michael Bayer (@zzzeek) wrote:
note this refers to all three of: mssql_drop_default, mssql_drop_check, mssql_drop_foreign_key
the related issue is #186 which was fixed.
While it would be nice for this flag to automatically render, this is a fairly special case for now and other than having it render unconditionally in all cases, which would be wasteful, I don’t have a solution right now for how this flag could always come out correctly. If we look into doing a generalized ENUM solution, that would be separate from this.