Fixed #19750 Postgres conflict on CREATE INDEX: "relation exists" #1813

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
@pricco

pricco commented Oct 26, 2013

#19750 Improve index name on postgres in order to avoid name conflicts.


Failing test

Django Version: stable/1.5.x

pip install git+git://github.com/django/django.git@stable/1.5.x#egg=Django

models.py

from django.db import models

class OrganizationType(models.Model):
    id = models.CharField(max_length=1, primary_key=True)

    class Meta:
        db_table = 'organization_type'

class Organization(models.Model):
    type = models.ForeignKey(OrganizationType)
    class Meta:
        db_table = 'organization'

./manage.py sqlall

BEGIN;
CREATE TABLE "organization_type" (
    "id" varchar(1) NOT NULL PRIMARY KEY,
    "name" varchar(10) NOT NULL
)
;
CREATE TABLE "organization" (
    "id" serial NOT NULL PRIMARY KEY,
    "type_id" varchar(1) NOT NULL REFERENCES "organization_type" ("id") DEFERRABLE INITIALLY DEFERRED
)
;
CREATE INDEX "organization_type_id_like" ON "organization_type" ("id" varchar_pattern_ops);
CREATE INDEX "organization_type_id" ON "organization" ("type_id");
CREATE INDEX "organization_type_id_like" ON "organization" ("type_id" varchar_pattern_ops);

COMMIT;
@timgraham

This comment has been minimized.

Show comment Hide comment
@timgraham

timgraham Nov 10, 2013

Member

Closing this based on the comment on the ticket that this doesn't appear to be the ideal solution. Please send a new PR if you can update it based on that comment, thanks!

Member

timgraham commented Nov 10, 2013

Closing this based on the comment on the ticket that this doesn't appear to be the ideal solution. Please send a new PR if you can update it based on that comment, thanks!

@timgraham timgraham closed this Nov 10, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment