question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when running migrations on MySQL 8+ or MariaDB

See original GitHub issue

Hi there,

I have an error I’m unable to fix.

Brand new virtualenv, new database. Mysql 5.5.42

When I’m trying to run migrations for django cms, I keep having an issue with 0008_auto_20150121_0059

Error message is ValueError: Found wrong number (0) of constraints for cms_page(publisher_is_draft, application_namespace)

Stack trace

(env) iMac-de-Louis:mysite louis$ python manage.py migrate cms 0008_auto_20150121_0059
Operations to perform:
  Target specific migration: 0008_auto_20150121_0059, from cms
Running migrations:
  Rendering model states... DONE
  Applying cms.0008_auto_20150121_0059...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 222, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 110, in migrate
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 148, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/db/migrations/migration.py", line 115, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 359, in database_forwards
    getattr(new_model._meta, self.option_name, set()),
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 320, in alter_unique_together
    self._delete_composed_index(model, fields, {'unique': True}, self.sql_delete_unique)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/db/backends/mysql/schema.py", line 80, in _delete_composed_index
    return super(DatabaseSchemaEditor, self)._delete_composed_index(model, fields, *args)
  File "/Users/louis/Documents/WebProjects/Python/carspotter_beta2/carspotterbeta2/env/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 349, in _delete_composed_index
    ", ".join(columns),
ValueError: Found wrong number (0) of constraints for cms_page(publisher_is_draft, application_namespace)

Pip freeze

cmsplugin-filer==1.0.1
Django==1.8.8
django-appconf==1.0.2
django-classy-tags==0.8.0
django-cms==3.2.5
django-compressor==2.1
django-extensions==1.6.1
django-filer==1.1.1
django-formtools==1.0
django-mptt==0.8.6
django-polymorphic==0.8.1
django-rest-swagger==0.3.10
django-reversion==1.8.7
django-sekizai==0.10.0
Django-Select2==4.3.2
django-treebeard==4.0.1
djangocms-admin-style==1.2.4
djangocms-attributes-field==0.1.1
djangocms-column==1.7.0
djangocms-googlemap==0.5.2
djangocms-inherit==0.2.2
djangocms-link==2.0.1
djangocms-style==1.7.0
djangocms-text-ckeditor==3.2.1
djangorestframework==3.2.5
drf-nested-routers==0.11.1
easy-thumbnails==2.3
html5lib==1.0b8
MySQL-python==1.2.5
Pillow==3.3.1
pytz==2016.6.1
PyYAML==3.12
rcssmin==1.0.6
rjsmin==1.0.12
six==1.10.0
Unidecode==0.4.19
wheel==0.26.0

The migration file content (relevant part):

migrations.AlterUniqueTogether(
            name='page',
            unique_together=set([('reverse_id', 'site', 'publisher_is_draft'), ('publisher_is_draft', 'site', 'application_namespace')]),
        )

What am I missing ? Packages incompatibility ? MySQL version issue ? Django version issue ? I even updated to Django 1.8.14 but still the same error.

Thanks !

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
ursomniaccommented, Nov 8, 2017

If you hack the migration file 0002_auto_20140816_1918.py and change line 67 from:

unique_together=set([('publisher_is_draft', 'application_namespace'), ('reverse_id', 'site', 'publisher_is_draft')]),

to

unique_together=set([('publisher_is_draft', 'site', 'application_namespace'), ('reverse_id', 'site', 'publisher_is_draft')]),

the issue goes away. (For some reason the problem ONLY happened if I used MariaDB: MySQL and Postgres installed out-of-the-box.)

1reaction
adamthcommented, Aug 22, 2018

I was having the same issue and found that migrations will run using MySQL 5.7. I would get the error when using MySQL 8. HTH

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when running migrations on MySQL 8+ or MariaDB
I've installed Django CMS 3.4 on a new virtualenv, same issue when running migrate for the first time. I wonder if that's an...
Read more >
Migrate from MySQL 8 to MariaDB 10.3.24 - HowTo?
Re: Migrate from MySQL 8 to MariaDB 10.3.24 - HowTo? the question is what exactly was not working properly? usually, one can take...
Read more >
Dealing with Failed SQL Migrations in MariaDB or MySQL
We get an unspecified error with: 'Migration of schema 'dbo' to version “1.1.7 – Add Indexes” failed! Please restore backups and roll back ......
Read more >
Error migrating from MySQL to MariaDB
Hi guys, I am trying to migrate a website using the free version of your plugin, and I ran into a database error....
Read more >
Issue When Running Django Migrations on MariaDB 10.5.8
In the end, to exchange the driver / db connector worked for me: Remove the mysqlclient from the dependencies.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found