summaryrefslogtreecommitdiff
path: root/migrate/changeset/schema.py
diff options
context:
space:
mode:
authorchrisw <unknown>2010-09-09 15:38:42 +0100
committerchrisw <unknown>2010-09-09 15:38:42 +0100
commitadf4113a0b8465dc67ea4002da3bc153eb4653db (patch)
tree4307d9d2b7cad2f720287d38017b49d038e763f1 /migrate/changeset/schema.py
parenta085ffa59048e10f8a874ea649aecf3335b4ab79 (diff)
downloadsqlalchemy-migrate-adf4113a0b8465dc67ea4002da3bc153eb4653db.tar.gz
Fix issue 94 - it was impossible to add a column with a non-unique index.
Also implement more functionality with unique and foreign key constrains for sqlite.
Diffstat (limited to 'migrate/changeset/schema.py')
-rw-r--r--migrate/changeset/schema.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/migrate/changeset/schema.py b/migrate/changeset/schema.py
index bf5aebe..ef8dd85 100644
--- a/migrate/changeset/schema.py
+++ b/migrate/changeset/schema.py
@@ -8,6 +8,7 @@ from UserDict import DictMixin
import sqlalchemy
from sqlalchemy.schema import ForeignKeyConstraint
+from sqlalchemy.schema import UniqueConstraint
from migrate.exceptions import *
from migrate.changeset import SQLA_06
@@ -570,6 +571,9 @@ populated with defaults
if table is not None and self.table is None:
self._set_parent(table)
+ def _col_name_in_constraint(self,cons,name):
+ return False
+
def remove_from_table(self, table, unset_table=True):
# TODO: remove primary keys, constraints, etc
if unset_table:
@@ -590,14 +594,13 @@ populated with defaults
to_drop = set()
for cons in table.constraints:
# TODO: deal with other types of constraint
- if isinstance(cons,ForeignKeyConstraint):
- col_names = []
+ if isinstance(cons,(ForeignKeyConstraint,
+ UniqueConstraint)):
for col_name in cons.columns:
if not isinstance(col_name,basestring):
col_name = col_name.name
- col_names.append(col_name)
- if self.name in col_names:
- to_drop.add(cons)
+ if self.name==col_name:
+ to_drop.add(cons)
table.constraints = table.constraints - to_drop
if table.c.contains_column(self):