Migration fails on MySQL when upgrading to Wagtail>=2.12rc1
See original GitHub issueIssue 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:
- Install Wagtail
< 2.12>= 2.12rc1 withpip install 'wagtail<2.12'
pip install 'wagtail>=2.12rc1<=2.12.2'
- Start a new project
wagtail start testproject
- Configure the
DATABASES
setting to use a MySQL database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'testproject',
'USER': 'testuser',
'PASSWORD': 'testpass'
}
}
- Prepare the database
mysql> create database testproject;
mysql> create user 'testuser'@'localhost' identified by 'testpass';
mysql> grant all privileges on testproject.* to 'testuser'@'localhost';
- 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:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
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.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).