diff --git a/migrate-0.7-compat.patch b/migrate-0.7-compat.patch new file mode 100644 index 0000000..1ff795a --- /dev/null +++ b/migrate-0.7-compat.patch @@ -0,0 +1,78 @@ +diff -Naur sqlalchemy-migrate-0.6.orig/migrate/changeset/__init__.py sqlalchemy-migrate-0.6/migrate/changeset/__init__.py +--- sqlalchemy-migrate-0.6.orig/migrate/changeset/__init__.py 2010-07-04 08:24:21.000000000 +0000 ++++ sqlalchemy-migrate-0.6/migrate/changeset/__init__.py 2011-12-04 22:36:17.849710345 +0000 +@@ -11,6 +11,7 @@ + + _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 -Naur sqlalchemy-migrate-0.6.orig/migrate/changeset/schema.py sqlalchemy-migrate-0.6/migrate/changeset/schema.py +--- sqlalchemy-migrate-0.6.orig/migrate/changeset/schema.py 2010-07-11 16:26:39.000000000 +0000 ++++ sqlalchemy-migrate-0.6/migrate/changeset/schema.py 2011-12-04 22:36:54.562808367 +0000 +@@ -6,7 +6,7 @@ + + import sqlalchemy + +-from migrate.changeset import SQLA_06 ++from migrate.changeset import SQLA_06, SQLA_07 + from migrate.changeset.exceptions import * + from migrate.changeset.databases.visitor import (get_engine_visitor, + run_single_visitor) +@@ -556,14 +556,20 @@ + + def add_to_table(self, table): + if table is not None and self.table is None: +- self._set_parent(table) ++ if SQLA_07: ++ table.append_column(self) ++ else: ++ self._set_parent(table) + + def remove_from_table(self, table, unset_table=True): + # TODO: remove indexes, primary keys, constraints, etc + if unset_table: + self.table = None + 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): +diff -Naur sqlalchemy-migrate-0.6.orig/migrate/versioning/schema.py sqlalchemy-migrate-0.6/migrate/versioning/schema.py +--- sqlalchemy-migrate-0.6.orig/migrate/versioning/schema.py 2010-07-04 08:24:22.000000000 +0000 ++++ sqlalchemy-migrate-0.6/migrate/versioning/schema.py 2011-12-04 22:36:34.746755563 +0000 +@@ -10,6 +10,7 @@ + from sqlalchemy import exceptions as sa_exceptions + from sqlalchemy.sql import bindparam + ++from migrate.changeset import SQLA_07 + from migrate.versioning import exceptions, genmodel, schemadiff + from migrate.versioning.repository import Repository + from migrate.versioning.util import load_model +@@ -56,10 +57,16 @@ + """ + Remove version control from a database. + """ +- try: +- self.table.drop() +- except (sa_exceptions.SQLError): +- raise exceptions.DatabaseNotControlledError(str(self.table)) ++ if SQLA_07: ++ try: ++ self.table.drop() ++ except (sa_exceptions.DatabaseError): ++ raise exceptions.DatabaseNotControlledError(str(self.table)) ++ else: ++ try: ++ self.table.drop() ++ except (sa_exceptions.SQLError): ++ raise exceptions.DatabaseNotControlledError(str(self.table)) + + def changeset(self, version=None): + """API to Changeset creation. diff --git a/python-migrate.spec b/python-migrate.spec index 773d5bc..81906ac 100644 --- a/python-migrate.spec +++ b/python-migrate.spec @@ -19,6 +19,8 @@ Patch0: migrate-scripttest-update.patch Patch1: migrate-py27.patch # Fix invalid code causing an exception Patch2: migrate-fix-deprecation-warning.patch +# Support sqlalchemy 0.7 +Patch3: migrate-0.7-compat.patch # Local patch to rename /usr/bin/migrate to sqlalchemy-migrate Patch100: python-migrate-sqlalchemy-migrate.patch @@ -61,6 +63,7 @@ atabase change sets and database repository versioning. %patch0 -p1 -b .test %patch1 -p1 -b .py27 %patch2 -p1 -b .exception +%patch3 -p1 -b .compat %patch100 -p0 -b .rename # use real unittest in python 2.7 and up @@ -101,6 +104,7 @@ nosetests %changelog * Sun Dec 04 2011 Pádraig Brady - 0.6-6 - Fix a crash when trying to issue a deprecation warning +- Backport sqlalchemy 0.7 support * Wed Nov 16 2011 Toshio Kuratomi - 0.6-5 - Require python-tempita