#36598: Django migrations is unable to find remove constraints from non-public
schema for Postgres
-------------------------------------+-------------------------------------
Reporter: Salaah Amin | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: postgres, db, orm | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tanishq):
Hi Salaah,
I’ve looked into the problem with migrations failing to remove constraints
from the {{{analytics.occupancy}}}table in a non-public schema, and it
seems related
to
{{{django.db.backends.postgresql.introspection.DatabaseIntrospection.get_constraints}}}
not detecting constraints due to
the{{{pg_catalog.pg_table_is_visible(cl.oid)}}}filter, despite
the{{{search_path=public,analytics}}}setting
in{{{DATABASES["OPTIONS"]}}}.The{{{ValueError: Found wrong number (0) of
constraints}}}suggests that the introspection query isn’t picking up
schema-qualified constraints during removal operations. This could be a
bug or a missing feature, as creation works fine. A potential fix might
involve modifying {{{get_constraints}}}to either:
Use the schema from{{{db_table}}}(e.g., "{{{analytics"."occupancy}}}")
explicitly in the query, or Adjust the SQL to include the schema in the
{{{JOIN}}} condition, bypassing the visibility filter when the schema is
specified.
--
Ticket URL: <https://code.djangoproject.com/ticket/36598#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019939b0337d-ffcf03c1-e94c-46d9-bd40-b4e54b43e3c4-000000%40eu-central-1.amazonses.com.