MySQLdb._exceptions.OperationalError: (1467, 'Failed to read auto-increment value from storage engine')
In Django, when you specify an implicit id, the above error occurs if the auto increment value reaches its upper limit.
Checking the database:
SELECT AUTO_INCREMENT
FROM information_schema.tables
WHERE TABLE_SCHEMA = 'my_schema'
AND TABLE_NAME = 'my_table';
AUTO_INCREMENT |
2147483647 |
SHOW CREATE TABLE my_table;
CREATE TABLE `my_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
...
Modifying the model:
id = models.BigAutoField(primary_key=True)
Adding the above line
./manage.py makemigrations
./manage.py migrate
SHOW CREATE TABLE my_table;
CREATE TABLE `my_table` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
...
Comments