Closed ajmatsick closed 6 years ago
Unfortunately I checked the open issues before submitting this, but not the open pull requests. I just saw that #519 addresses the same thing. I can close this if that's going to be merged instead.
whatever gets this fix going!
Fixed by #519
With the addition of class-based indexes in Django 1.11, some changes were made to the way index and constraint data is retrieved and returned in
django/db/backends/postgresql/introspection.py
.See:
Of note:
dict
inDatabaseIntrospection.get_constraints()
now includes anoptions
keytype
value is nowdjango.db.models.indexes.Index.suffix
for instead ofbtree
for B-tree indexesAs far as I can tell the omission of the
options
key doesn't currently have an effect, though it may in the future when using class-based indexes. The incorrecttype
value, however, can cause errors when changing thedb_index
andunique
values for model fields.For example, consider a model field that has an index and is then modified to add a unique constraint:
This migration will fail with an error similar to this:
This is because the existing index names are not collected correctly (see django/db/backends/base/schema.py), meaning the existing index is not removed before being added again later (here).
To fix this,
tenant_schemas/postgresql_backend/introspection.py
should be updated to reflect the changes indjango/db/backends/postgresql/introspection.py
.