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.

Migration fails on MySQL when upgrading to Wagtail>=2.12rc1

See original GitHub issue

Issue Summary

The wagtailembeds.0008_allow_long_urls migration added in 2.12rc1 (https://github.com/wagtail/wagtail/commit/32ade8672fe32223b6ebdcb2255bf4de16908f97) results in the following error on MySQL 8.0 (and presumably also older versions):

MySQLdb._exceptions.OperationalError:
(1101, "BLOB, TEXT, GEOMETRY or JSON column 'thumbnail_url' can't have a default value")

This is expected behaviour. According to https://dev.mysql.com/doc/refman/8.0/en/blob.html:

BLOB and TEXT columns cannot have DEFAULT values.

Steps to Reproduce

Update: Migration from 2.11 to 2.12 is not needed; can be reproduced more simply in steps 1–5 using 2.12rc1<=wagtail<=2.12.2

This issue can be reproduced on a fresh Wagtail project as follows:

  1. Install Wagtail < 2.12 >= 2.12rc1 with pip install 'wagtail<2.12' pip install 'wagtail>=2.12rc1<=2.12.2'
  2. Start a new project wagtail start testproject
  3. Configure the DATABASES setting to use a MySQL database
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'testproject',
        'USER': 'testuser',
        'PASSWORD': 'testpass'
    }
}
  1. Prepare the database
mysql> create database testproject;
mysql> create user 'testuser'@'localhost' identified by 'testpass';
mysql> grant all privileges on testproject.* to 'testuser'@'localhost';
  1. Run initial migrations ./manage.py migrate 6. Upgrade to Wagtail 2.12rc1 or greater with, e.g. pip install --upgrade wagtail==2.12.2 7. Re-run migrations ./manage.py migrate

Additional Notes

Prior to MySQL 8.0.13, BLOB and TEXT could not be assigned DEFAULT values. As of 8.0.13, they can be assigned defaults, but only in the form of expressions as noted in https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html#data-type-defaults-explicit

Technical details

  • Python 3.8.3
  • Django 3.1.7
  • Wagtail 2.11.5 -> 2.12rc1…2.12.2
  • MySQL 8.0.21 for osx10.15 on x86_64 (Homebrew)
  • mysqlclient 2.0.3

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
suxilogcommented, Mar 3, 2021

Any update for this issue? Also meet this problem django.db.utils.OperationalError: (1101, "BLOB, TEXT, GEOMETRY or JSON column 'thumbnail_url' can't have a default value") All works good on wagtail 2.11.3.

0reactions
gasmancommented, Apr 12, 2021

Reopening as this is a hard blocker to anyone on current MySQL from upgrading to 2.12, and fortunately there’s a fairly simple workaround (PR to follow shortly).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix error upgrading Wagtail 2.10.2 to 2.11.8?
Run through the Wagtail upgrade sequence as before, upgrading one version at a time and running ./manage.py makemigrations and .
Read more >
Migration errors setting up wagtail with MySQL : Forums
Hello,. I'm having trouble setting up Wagtail on pythonanywhere MySQL database. I ran makemigrations and migrate and all the tables were created ...
Read more >
Error migrating from MySQL to MariaDB - WordPress.org
The migration is from a Google Cloud instance with MySQL, and the target is an AWS lightsail instance with MariaDB. These are the...
Read more >
Migrating your Wagtail site to a different database engine
You can use it go from SQLite to PostgreSQL or MySQL, but you can ... The error above is because I'm migrating from...
Read more >
MySQL error upgrading to 4.2 - Mautic Forums
No I am updating via command line. Another failed upgrade (4.3.1) on stuck database migration, SQL syntax error.
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