summaryrefslogtreecommitdiff
path: root/alembic/operations/schemaobj.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-07-03 17:29:17 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-07-03 17:37:44 -0400
commita294f8cc3f2e5fc2cad048bc4ce27c57554e2688 (patch)
tree335359e7a973aea5289b7597d27d1f87cf1dc822 /alembic/operations/schemaobj.py
parentad5390c0e344008014bcbc8edfe1050ce465ede2 (diff)
downloadalembic-a294f8cc3f2e5fc2cad048bc4ce27c57554e2688.tar.gz
- Implemented support for :meth:`.BatchOperations.create_primary_key`
and :meth:`.BatchOperations.create_check_constraint`. fixes #305 - table keyword arguments are copied from the original reflected table, such as the "mysql_engine" keyword argument.
Diffstat (limited to 'alembic/operations/schemaobj.py')
-rw-r--r--alembic/operations/schemaobj.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/alembic/operations/schemaobj.py b/alembic/operations/schemaobj.py
index b590aca..f0f8105 100644
--- a/alembic/operations/schemaobj.py
+++ b/alembic/operations/schemaobj.py
@@ -12,11 +12,13 @@ class SchemaObjects(object):
def primary_key_constraint(self, name, table_name, cols, schema=None):
m = self.metadata()
columns = [sa_schema.Column(n, NULLTYPE) for n in cols]
- t1 = sa_schema.Table(table_name, m,
- *columns,
- schema=schema)
- p = sa_schema.PrimaryKeyConstraint(*columns, name=name)
- t1.append_constraint(p)
+ t = sa_schema.Table(
+ table_name, m,
+ *columns,
+ schema=schema)
+ p = sa_schema.PrimaryKeyConstraint(
+ *[t.c[n] for n in cols], name=name)
+ t.append_constraint(p)
return p
def foreign_key_constraint(