summaryrefslogtreecommitdiff
path: root/alembic
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-03-10 11:26:43 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-03-10 11:26:43 -0400
commit46761f9d868c40e0eacac45dac32fdce20bb6f7b (patch)
tree0b08073e313d826c8caa1fb8238e6b265eb56816 /alembic
parent6443b29042cde2c36497fad06ba55b93d9e7a2e1 (diff)
downloadalembic-46761f9d868c40e0eacac45dac32fdce20bb6f7b.tar.gz
- 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
Diffstat (limited to 'alembic')
-rw-r--r--alembic/ddl/postgresql.py22
1 files changed, 21 insertions, 1 deletions
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):