diff mbox series

[v3,2/5] migrations: Correct 'unique_together' order in '0015'

Message ID 20190608173622.6711-3-stephen@that.guru
State Accepted
Headers show
Series Integrate tox-docker | expand

Commit Message

Stephen Finucane June 8, 2019, 5:36 p.m. UTC
This was resulting in exceptions like the following when used with MySQL
8.0:

  Traceback (most recent call last):
    File "../patchwork/manage.py", line 11, in <module>
      execute_from_command_line(sys.argv)
    ...
    File "../.tox/py27-django111/lib/python2.7/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 "../.tox/py27-django111/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 394, in _delete_composed_index
      ", ".join(columns),
  ValueError: Found wrong number (0) of constraints for patchwork_seriespatch(series_id, number)

This error was being raised by the following lines in the 0033
migration:

  migrations.AlterUniqueTogether(
      name='seriespatch',
      unique_together=set([]),
  )

It appears that this is because of a mismatch between the order of
fields in a 'unique_together' constraint [1]. Correct the order in the
original migration and see the issue disappear.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: d67d859f40f ("models: Add 'Series' model")
---
 patchwork/migrations/0015_add_series_models.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Finucane Aug. 31, 2019, 12:04 p.m. UTC | #1
On Sat, 2019-06-08 at 18:36 +0100, Stephen Finucane wrote:
> This was resulting in exceptions like the following when used with MySQL
> 8.0:
> 
>   Traceback (most recent call last):
>     File "../patchwork/manage.py", line 11, in <module>
>       execute_from_command_line(sys.argv)
>     ...
>     File "../.tox/py27-django111/lib/python2.7/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 "../.tox/py27-django111/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 394, in _delete_composed_index
>       ", ".join(columns),
>   ValueError: Found wrong number (0) of constraints for patchwork_seriespatch(series_id, number)
> 
> This error was being raised by the following lines in the 0033
> migration:
> 
>   migrations.AlterUniqueTogether(
>       name='seriespatch',
>       unique_together=set([]),
>   )
> 
> It appears that this is because of a mismatch between the order of
> fields in a 'unique_together' constraint [1]. Correct the order in the
> original migration and see the issue disappear.
> 
> Signed-off-by: Stephen Finucane <stephen@that.guru>
> Fixes: d67d859f40f ("models: Add 'Series' model")

Applied.
diff mbox series

Patch

diff --git a/patchwork/migrations/0015_add_series_models.py b/patchwork/migrations/0015_add_series_models.py
index b7c3dc76..72223906 100644
--- a/patchwork/migrations/0015_add_series_models.py
+++ b/patchwork/migrations/0015_add_series_models.py
@@ -62,6 +62,6 @@  class Migration(migrations.Migration):
         ),
         migrations.AlterUniqueTogether(
             name='seriespatch',
-            unique_together=set([('series', 'number'), ('series', 'patch')]),
+            unique_together=set([('series', 'patch'), ('series', 'number')]),
         ),
     ]