From 46761f9d868c40e0eacac45dac32fdce20bb6f7b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 10 Mar 2015 11:26:43 -0400 Subject: - Postgresql "functional" indexes are necessarily skipped from the autogenerate process, as the SQLAlchemy backend currently does not support reflection of these structures. A warning is emitted both from the SQLAlchemy backend as well as from the Alembic backend for Postgresql when such an index is detected. fixes #282 --- alembic/ddl/postgresql.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'alembic') diff --git a/alembic/ddl/postgresql.py b/alembic/ddl/postgresql.py index ac3a5f4..1002687 100644 --- a/alembic/ddl/postgresql.py +++ b/alembic/ddl/postgresql.py @@ -1,10 +1,17 @@ import re from .. import compat +from .. import util from .base import compiles, alter_table, format_table_name, RenameTable from .impl import DefaultImpl from sqlalchemy.dialects.postgresql import INTEGER, BIGINT -from sqlalchemy import text, Numeric +from sqlalchemy import text, Numeric, Column + +if compat.sqla_08: + from sqlalchemy.sql.expression import UnaryExpression +else: + from sqlalchemy.sql.expression import _UnaryExpression as UnaryExpression + import logging log = logging.getLogger(__name__) @@ -97,6 +104,19 @@ class PostgresqlImpl(DefaultImpl): for name, (uq, ix) in doubled_constraints.items(): conn_indexes.remove(ix) + for idx in list(metadata_indexes): + if compat.sqla_08: + exprs = idx.expressions + else: + exprs = idx.columns + for expr in exprs: + if not isinstance(expr, (Column, UnaryExpression)): + util.warn( + "autogenerate skipping functional index %s; " + "not supported by SQLAlchemy reflection" % idx.name + ) + metadata_indexes.discard(idx) + @compiles(RenameTable, "postgresql") def visit_rename_table(element, compiler, **kw): -- cgit v1.2.1