
Version 0.8 of SQLAlchemy added support of indexes on expressions in addition to plain table columns, which changed the way indexes are created. This broke support of dropping columns of composite indexes for SQLite: due to limitations of ALTER in SQLite every time a column is dropped, we recreate the whole table without the given column; if a column is a part of a composite index, we change the index definition to omit that column and then indexes are recreated too. SQLAlchemy versions starting from 0.8 no more pay attention to 'columns' attribute of Index instances when generating DDL for indexes, so when one of columns of a composite index is dropped, we try to create a new index on the column that doesn't exist anymore, which of course fails. Closes-Bug: #1241038 Change-Id: I777b8ce36e36f49bfb0889908811a063cf1a527b
30 lines
777 B
Python
30 lines
777 B
Python
"""
|
|
This module extends SQLAlchemy and provides additional DDL [#]_
|
|
support.
|
|
|
|
.. [#] SQL Data Definition Language
|
|
"""
|
|
import re
|
|
import warnings
|
|
|
|
import sqlalchemy
|
|
from sqlalchemy import __version__ as _sa_version
|
|
|
|
warnings.simplefilter('always', DeprecationWarning)
|
|
|
|
_sa_version = tuple(int(re.match("\d+", x).group(0)) for x in _sa_version.split("."))
|
|
SQLA_07 = _sa_version >= (0, 7)
|
|
SQLA_08 = _sa_version >= (0, 8)
|
|
|
|
del re
|
|
del _sa_version
|
|
|
|
from migrate.changeset.schema import *
|
|
from migrate.changeset.constraint import *
|
|
|
|
sqlalchemy.schema.Table.__bases__ += (ChangesetTable, )
|
|
sqlalchemy.schema.Column.__bases__ += (ChangesetColumn, )
|
|
sqlalchemy.schema.Index.__bases__ += (ChangesetIndex, )
|
|
|
|
sqlalchemy.schema.DefaultClause.__bases__ += (ChangesetDefaultClause, )
|