#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
> 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)
> }}}
>
> 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
 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)
 }}}

 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 <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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.2827664408d0d81d6b7f2f94336b9ef5%40djangoproject.com.

Reply via email to