[Django] #31332: migration error

4 views
Skip to first unread message

Django

unread,
Mar 2, 2020, 4:30:48 PM3/2/20
to django-...@googlegroups.com
#31332: migration error
--------------------------------------+------------------------
Reporter: ashukla95 | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.11
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 |
--------------------------------------+------------------------
I have a database table that currently has uniqueness constraint over
three columns. I added one more column to this uniqueness constraint.
So, the Meta class with the new uniqueness constraints looks as follows:
class Meta:
unique_together = ('batch_size', 'distributor', 'service', 'type')
On running makemigrations command, I get the following error:
Running migrations:
Applying
shopping.0061_alter_distributorprice_uniqueness_constraint...Traceback
(most recent call last):
ile "manage_lims.py", line 14, in <module>
manage.main()
File "/home/addgene/addgene-core/src/django/manage.py", line 20, in main
execute_from_command_line(sys.argv)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/core/management/__init__.py", line 364, in
execute_from_command_line
utility.execute()
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake,
fake_initial=fake_initial)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/db/migrations/executor.py", line 145, in
_migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake,
fake_initial=fake_initial)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state,
project_state)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/db/migrations/operations/models.py", line 536, in
database_forwards
getattr(new_model._meta, self.option_name, set()),
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/db/backends/base/schema.py", line 365, in
alter_unique_together
self._delete_composed_index(model, fields, {'unique': True},
self.sql_delete_unique)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/db/backends/mysql/schema.py", line 88, in
_delete_composed_index
return super(DatabaseSchemaEditor, self)._delete_composed_index(model,
fields, *args)
File "/srv/addgene-py3/lib/python3.5/site-
packages/django/db/backends/base/schema.py", line 394, in
_delete_composed_index
", ".join(columns),
ValueError: Found wrong number (0) of constraints for
shopping_distributorprice(batch_size, distributor_id, service_id)

--
Ticket URL: <https://code.djangoproject.com/ticket/31332>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 2, 2020, 4:32:25 PM3/2/20
to django-...@googlegroups.com
#31332: migration error
----------------------------+--------------------------------------

Reporter: ashukla95 | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Description changed by ashukla95:

Old description:

New description:

I have already viewed and tested the tickets related to this error but
none work. I even tried to remove the constrain altogether to reapply a
new one, but still I get the same error as above.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31332#comment:1>

Django

unread,
Mar 2, 2020, 4:37:12 PM3/2/20
to django-...@googlegroups.com
#31332: migration error
----------------------------+--------------------------------------

Reporter: ashukla95 | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Description changed by ashukla95:

Old description:

> I have a database table that currently has uniqueness constraint over

> I have already viewed and tested the tickets related to this error but
> none work. I even tried to remove the constrain altogether to reapply a
> new one, but still I get the same error as above.

New description:

I have already viewed and tested the tickets related to this error but
none work. I even tried to remove the constraint altogether to reapply a


new one, but still I get the same error as above.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31332#comment:2>

Django

unread,
Mar 2, 2020, 4:37:30 PM3/2/20
to django-...@googlegroups.com
#31332: migration error
----------------------------+--------------------------------------

Reporter: ashukla95 | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Description changed by ashukla95:

Old description:

> I have a database table that currently has uniqueness constraint over

> I have already viewed and tested the tickets related to this error but
> none work. I even tried to remove the constraint altogether to reapply a
> new one, but still I get the same error as above.

New description:

I have already viewed and tested the tickets related to this error but


none work. I even tried to remove the constraint altogether to reapply a
new one, but still I get the same error as above.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31332#comment:3>

Django

unread,
Mar 2, 2020, 4:37:48 PM3/2/20
to django-...@googlegroups.com
#31332: migration error
----------------------------+--------------------------------------

Reporter: ashukla95 | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Description changed by ashukla95:

Old description:

> I have a database table that currently has uniqueness constraint over

> I have already viewed and tested the tickets related to this error but
> none work. I even tried to remove the constraint altogether to reapply a
> new one, but still I get the same error as above.

New description:

I have a database table that currently has uniqueness constraint over

I have already viewed and tested the tickets related to this error but


none work. I even tried to remove the constraint altogether to reapply a
new one, but still I get the same error as above.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31332#comment:4>

Django

unread,
Mar 3, 2020, 3:09:42 AM3/3/20
to django-...@googlegroups.com
#31332: Constraint detection fails when altering unique_together on MySQL.
----------------------------+--------------------------------------
Reporter: Aishwary | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.11
Severity: Normal | Resolution: worksforme

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by felixxm):

* status: new => closed
* resolution: => worksforme


Comment:

It works for me on the current master. Django 1.11 doesn't receive
bugfixes anymore so you have to reproduce this on Django 3.0+. Please
feel-free to reopen this ticket if you can provide a sample project that
fails on the current master branch.

--
Ticket URL: <https://code.djangoproject.com/ticket/31332#comment:5>

Reply all
Reply to author
Forward
0 new messages