Opened 9 years ago

Closed 8 years ago

#25049 closed Bug (duplicate)

Oracle fails to change unique_together constraints due to case sensitivity

Reported by: Pogsquog Owned by: nobody
Component: Migrations Version: 1.8
Severity: Normal Keywords: Oracle constraints migration case
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

When using Oracle, migrations which alter the unique constraints of a model do not migrate correctly. This appears to be due to a case sensitivity difference in Oracle vs other databases.

Tested on Django 1.8 and 1.7 with Oracle 12c

example: models.py

from django.db import models

class DoorCount(models.Model):
    Day = models.DateField()
    MinuteOfTheDay = models.PositiveIntegerField()
    DoorId = models.PositiveIntegerField(null=False, blank=False)
    LineId = models.PositiveIntegerField(null=False, blank=False, default=0)
    Count = models.PositiveIntegerField(default=0)

    class Meta:
        # unique_together = ("Day", "MinuteOfTheDay", "DoorId", "LineId") # migration initial 0001
        unique_together = ("Day", "MinuteOfTheDay", "DoorId", "LineId")  # migration 0002

run makemigration with initial
run makemigration with 0002
run migrate
gets "Found wrong number (0) of constraints for TestApp_doorcount(Day, MinuteOfTheDay, DoorId)"

Problem appears to be case sensitivity when looking for field names, so it does not find the relevant constraint in the database.

Currently I have a workaround to patch site-packages/django/db/schema.py with a .lower() on constraints, but this is very annoying for deploying, and is probably better fixed in the oracle specific code.

Change History (4)

comment:1 by Tim Graham, 9 years ago

Description: modified (diff)
Easy pickings: unset

comment:2 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

I haven't reproduced the issue myself, but it seems credible given #20487 and #24407.

comment:3 by Tim Graham, 8 years ago

Could you check if #26833 fixed this?

comment:4 by Tim Graham, 8 years ago

Component: Database layer (models, ORM)Migrations
Resolution: duplicate
Status: newclosed
Summary: Oracle constraints case sensitivityOracle fails to change unique_together constraints due to case sensitivity

Confirmed that #26833 fixed this.

Note: See TracTickets for help on using tickets.
Back to Top