{{{
DATABASES[default']['OPTIONS'] = {
'options': '-c
search_path={}'.format(get_env('POSTGRES_SCHEMA', 'public')),
}
}}}
The problem is that migrations fail, because methods like
`get_constraints` return constraints from other schemas:
https://github.com/django/django/blob/a3417282ac0464a9a2d1d7685bcfef10feed2597/django/db/backends/postgresql/introspection.py#L145
When I look deeper into that code, it looks that there is a mess with
schemas filtering.
1. The first SQL query in `get_constraints` will use hardcoded schema name
`public`:
https://github.com/django/django/blob/a3417282ac0464a9a2d1d7685bcfef10feed2597/django/db/backends/postgresql/introspection.py#L175
2. The second SQL in the same method doesn't filter by schema name, so it
will return entries from all schemas:
https://github.com/django/django/blob/a3417282ac0464a9a2d1d7685bcfef10feed2597/django/db/backends/postgresql/introspection.py#L214
3. `get_table_list` properly filters by using
`pg_catalog.pg_table_is_visible`.
4. `get_sequences` and `get_relations` will return entries from all
schemas.
--
Ticket URL: <https://code.djangoproject.com/ticket/30644>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => Bug
--
Ticket URL: <https://code.djangoproject.com/ticket/30644#comment:1>
* cc: Georgi Yanchev (added)
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/30644#comment:2>
* component: Uncategorized => Database layer (models, ORM)
--
Ticket URL: <https://code.djangoproject.com/ticket/30644#comment:3>
* keywords: => Postgres schemas
--
Ticket URL: <https://code.djangoproject.com/ticket/30644#comment:4>
* status: new => assigned
* version: 2.2 => master
* owner: nobody => Georgi Yanchev
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Thanks for this report. I agree that we can use `pg_table_is_visible` and
remove filtering by `public` schema in `get_sequences()` and
`get_constraints()`. Django doesn't support schema so it's rather a
cleanup to me.
[https://github.com/django/django/pull/11511 PR]
Comment: `get_sequences()` will return sequences only from public schema.
--
Ticket URL: <https://code.djangoproject.com/ticket/30644#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"c6581a40be3bb4c1e13861f0adbb3fe01f09107f" c6581a40]:
{{{
#!CommitTicketReference repository=""
revision="c6581a40be3bb4c1e13861f0adbb3fe01f09107f"
Fixed #30644 -- Made introspection use pg_table_is_visible() instead of
filtering by public schema on PostgreSQL.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30644#comment:6>