-
-
Notifications
You must be signed in to change notification settings - Fork 309
Closed
Labels
Description
PostgreSQL, a unique constraint with uppercase letters in name. _compare_indexes_and_uniques takes name as _constraint_sig.name (just the name without quotes) for constraint from connection, but as _constraint_sig.md_name_to_sql_name(context) (gives the name in double quotes) for constraint from metadata. That causes false changes detection with script that drops and creates the same constraint.
The following change solves the problem:
--- a/alembic/autogenerate/compare.py
+++ b/alembic/autogenerate/compare.py
@@ -541,7 +541,7 @@ def _compare_indexes_and_uniques(
conn_uniques_by_name = dict((c.name, c) for c in conn_unique_constraints)
conn_indexes_by_name = dict((c.name, c) for c in conn_indexes)
conn_names = dict(
- (c.name, c)
+ (c.md_name_to_sql_name(autogen_context), c)
for c in conn_unique_constraints.union(conn_indexes)
if c.name is not None
)
Reactions are currently unavailable