summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorergo <none@none>2012-07-18 00:35:08 +0200
committerergo <none@none>2012-07-18 00:35:08 +0200
commitbbe847d5b8932d9c113d659a2807678aa8777ea1 (patch)
tree368d31be151e2dd2e8b8e52127dbdc22f94613c0
parent62b664fab8ab12aa9bb19cefd982c47e12d0bf57 (diff)
downloadalembic-bbe847d5b8932d9c113d659a2807678aa8777ea1.tar.gz
added drop primary key constraint
-rw-r--r--alembic/operations.py3
-rw-r--r--tests/test_mysql.py7
2 files changed, 9 insertions, 1 deletions
diff --git a/alembic/operations.py b/alembic/operations.py
index 4297a25..1d59df3 100644
--- a/alembic/operations.py
+++ b/alembic/operations.py
@@ -565,13 +565,14 @@ class Operations(object):
:param name: name of the constraint.
:param tablename: tablename.
:param type: optional, required on MySQL. can be
- 'foreignkey', 'unique', or 'check'
+ 'foreignkey', 'primary', 'unique', or 'check'
"""
t = self._table(tablename)
types = {
'foreignkey':lambda name:schema.ForeignKeyConstraint(
[], [], name=name),
+ 'primary':schema.PrimaryKeyConstraint,
'unique':schema.UniqueConstraint,
'check':lambda name:schema.CheckConstraint("", name=name),
None:schema.Constraint
diff --git a/tests/test_mysql.py b/tests/test_mysql.py
index 4c4a357..548217e 100644
--- a/tests/test_mysql.py
+++ b/tests/test_mysql.py
@@ -48,6 +48,13 @@ def test_drop_fk():
"ALTER TABLE t1 DROP FOREIGN KEY f1"
)
+def test_drop_constraint_primary():
+ context = op_fixture('mysql')
+ op.drop_constraint('primary', 't1',type='primary')
+ context.assert_(
+ "ALTER TABLE t1 DROP PRIMARY KEY "
+ )
+
def test_drop_unique():
context = op_fixture('mysql')
op.drop_constraint("f1", "t1", "unique")