Opened 5 years ago
Last modified 5 years ago
#31332 closed Bug
migration error — at Initial Version
Reported by: | Aishwary | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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)