return operations.invoke(op)
@classmethod
- def batch_drop_column(cls, operations, column_name):
+ def batch_drop_column(cls, operations, column_name, **kw):
"""Issue a "drop column" instruction using the current
batch migration context.
"""
op = cls(
operations.impl.table_name, column_name,
- schema=operations.impl.schema)
+ schema=operations.impl.schema, **kw)
return operations.invoke(op)
"exec('alter table t1 drop constraint ' + @const_name)")
context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
+ def test_drop_column_w_default_in_batch(self):
+ context = op_fixture('mssql')
+ with op.batch_alter_table('t1', schema=None) as batch_op:
+ batch_op.drop_column('c1', mssql_drop_default=True)
+ batch_op.drop_column('c2', mssql_drop_default=True)
+ context.assert_contains(
+ "exec('alter table t1 drop constraint ' + @const_name)")
+ context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
+
def test_alter_column_drop_default(self):
context = op_fixture('mssql')
op.alter_column("t", "c", server_default=None)
"exec('alter table t1 drop constraint ' + @const_name)")
context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
+ def test_drop_column_w_check_in_batch(self):
+ context = op_fixture('mssql')
+ with op.batch_alter_table('t1', schema=None) as batch_op:
+ batch_op.drop_column('c1', mssql_drop_check=True)
+ batch_op.drop_column('c2', mssql_drop_check=True)
+ context.assert_contains(
+ "exec('alter table t1 drop constraint ' + @const_name)")
+ context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
+
def test_drop_column_w_check_quoting(self):
context = op_fixture('mssql')
op.drop_column('table', 'column', mssql_drop_check=True)
"exec('alter table t1 drop constraint ' + @const_name)")
context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
+ def test_drop_column_w_fk_in_batch(self):
+ context = op_fixture('mssql')
+ with op.batch_alter_table('t1', schema=None) as batch_op:
+ batch_op.drop_column('c1', mssql_drop_foreign_key=True)
+ context.assert_contains(
+ "exec('alter table t1 drop constraint ' + @const_name)")
+ context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
+
def test_alter_column_not_nullable_w_existing_type(self):
context = op_fixture('mssql')
op.alter_column("t", "c", nullable=False, existing_type=Integer)