From e11a9e5cbaeb76fae1ed1d9b3614568be2520d92 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Wed, 25 May 2011 15:29:28 +0200 Subject: [PATCH] use Table._columns to remove columns (addresses #112) - add SQLA_07 predicate in migrate/changeset/__init__.py - use Table._columns instead of Table.c when removing columns in migrate/changeset/schema.py --- migrate/changeset/__init__.py | 1 + migrate/changeset/schema.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/migrate/changeset/__init__.py b/migrate/changeset/__init__.py index 7a12643..fa3387d 100644 --- a/migrate/changeset/__init__.py +++ b/migrate/changeset/__init__.py @@ -14,6 +14,7 @@ warnings.simplefilter('always', DeprecationWarning) _sa_version = tuple(int(re.match("\d+", x).group(0)) for x in _sa_version.split(".")) SQLA_06 = _sa_version >= (0, 6) +SQLA_07 = _sa_version >= (0, 7) del re del _sa_version diff --git a/migrate/changeset/schema.py b/migrate/changeset/schema.py index 75cd3fd..1bd3fc0 100644 --- a/migrate/changeset/schema.py +++ b/migrate/changeset/schema.py @@ -11,7 +11,7 @@ from sqlalchemy.schema import ForeignKeyConstraint from sqlalchemy.schema import UniqueConstraint from migrate.exceptions import * -from migrate.changeset import SQLA_06 +from migrate.changeset import SQLA_06, SQLA_07 from migrate.changeset.databases.visitor import (get_engine_visitor, run_single_visitor) @@ -590,7 +590,10 @@ populated with defaults table.constraints = table.constraints - to_drop if table.c.contains_column(self): - table.c.remove(self) + if SQLA_07: + table._columns.remove(self) + else: + table.c.remove(self) # TODO: this is fixed in 0.6 def copy_fixed(self, **kw):