]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
added drop primary key constraint
authorergo <none@none>
Tue, 17 Jul 2012 22:35:08 +0000 (00:35 +0200)
committerergo <none@none>
Tue, 17 Jul 2012 22:35:08 +0000 (00:35 +0200)
alembic/operations.py
tests/test_mysql.py

index 4297a2504bd13c025bdc8a7d356303ba39936313..1d59df3941005722b78f0da6e30af406496f1102 100644 (file)
@@ -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
index 4c4a357d0329087e66fb9032b2163341e226084a..548217e86b2c65c98b7907b3876b92184358f00d 100644 (file)
@@ -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")