#35383: Add support for `IF NOT EXISTS` when creating postgres indexes
concurrently
-------------------------------------+-------------------------------------
Reporter: marcelofern | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 5.0
Severity: Normal | Resolution:
Keywords: database, postgres, | Triage Stage:
index, concurrently | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Adam Johnson):
> This is not consistent with the pattern for other schema-change
operations, which already include either IF NOT EXISTS or IF EXISTS so
that changes fail without error.
That’s not true for `CREATE INDEX`, though:
https://github.com/django/django/blob/2be37b253341cfd1f1363c533e6f896230f047a7/django/db/backends/postgresql/schema.py#L17-L20
. To be honest, there doesn’t seem to be a consistent policy there.
> This is particularly important in my case. I have the same Django
project being deployed in different regions of the world.
I'd like to create the index concurrently out-of-business hours, which
varies depending on the country. Following that, I'd like to create the
migration file so that all environments are in sync.
In my opinion, your use case goes too far beyond Django to inform any
changes to the framework. You can use `RunSQL` within your migration with
the `IF NOT EXISTS` clause. That seems a small price to pay for enforcing
your particular deployment scheme.
--
Ticket URL: <https://code.djangoproject.com/ticket/35383#comment:1>
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 on the web visit
https://groups.google.com/d/msgid/django-updates/0107018eee0220ea-6d54f649-1fb6-4381-907b-68d156975f12-000000%40eu-central-1.amazonses.com.