I encountered an error during the application of migrations in my Django web application when using a MySQL database. Specifically, when attempting to apply migration 0004_alter_blacklistedtoken_id_and_more.py, the following error is raised:
Applying oauth2_authcodeflow.0004_alter_blacklistedtoken_id_and_more...Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/django/db/backends/utils.py", line 87, in _execute
return self.cursor.execute(sql)
File "/usr/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 75, in execute
return self.cursor.execute(query, args)
File "/usr/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/lib/python3.8/site-packages/MySQLdb/connections.py", line 254, in query
_mysql.connection.query(self, query)
MySQLdb.OperationalError: (1071, 'Specified key was too long; max key length is 3072 bytes')
Upon inspecting the previous migration (0003_auto_20210528_1432), I noticed that the issue is correctly handled and causes no problems. Below is the relevant snippet from 0003_auto_20210528_1432:
try:
migrations.AddConstraint(
model_name='blacklistedtoken',
constraint=models.UniqueConstraint(fields=('username', 'token'), name='unique_username_token'),
),
except Exception:
# no constraint on mysql, max key is 3072 bytes which is not enough
pass
Skipping the problematic migration (0004_alter_blacklistedtoken_id_and_more.py) doesn't seem to affect the functionality of the library, but resolving this issue would be preferable for a full compatibility.
I encountered an error during the application of migrations in my Django web application when using a MySQL database. Specifically, when attempting to apply migration 0004_alter_blacklistedtoken_id_and_more.py, the following error is raised:
Upon inspecting the previous migration (0003_auto_20210528_1432), I noticed that the issue is correctly handled and causes no problems. Below is the relevant snippet from 0003_auto_20210528_1432:
Skipping the problematic migration (0004_alter_blacklistedtoken_id_and_more.py) doesn't seem to affect the functionality of the library, but resolving this issue would be preferable for a full compatibility.