#34729: Add explicit option to enable IF EXISTS / IF NOT EXISTS in PostgresQL 
index
operations
--------------------------------------------+------------------------
               Reporter:  Laurent Tramoy    |          Owner:  (none)
                   Type:  New feature       |         Status:  new
              Component:  contrib.postgres  |        Version:  4.2
               Severity:  Normal            |       Keywords:
           Triage Stage:  Unreviewed        |      Has patch:  0
    Needs documentation:  0                 |    Needs tests:  0
Patch needs improvement:  0                 |  Easy pickings:  0
                  UI/UX:  0                 |
--------------------------------------------+------------------------
 Hello,

 I'd like to be able to add a `IF NOT EXISTS` clause when creating indexes
 (both with AddIndex and AddIndexConcurrently).

 I've read this ticket https://code.djangoproject.com/ticket/34298 where
 Mariusz considers it's a bad idea (for constraints), and I get his point,
 however I've a few counter arguments:
 * I feel like the workflow "add an index in a deployed environment /
 check it works as expected / add it to Django code" is quite common in
 "real-life" applications, for now we have to write a custom
 `SeparateDatabaseAndState` each time we do this
 * The idea would be to enable this explicitly (either by adding a
 `AddIndexIfNotExists` operation, or by adding a parameter to `AddIndex` /
 `AddIndexConcurrently`), so people should know what they're doing when
 using this.
 * The `IF EXISTS` clause is already used  when dropping the index, it
 would be more consistent to be able to allow it when adding the index too
 
[https://github.com/django/django/blob/afc880571d5f5a16b977070b15014f9583524898/django/db/backends/postgresql/schema.py#L25]

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34729>
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/010701897868dd71-583f0cb7-0f1b-4f0f-8ea7-6f349e5be731-000000%40eu-central-1.amazonses.com.

Reply via email to