I’m running HA Core in a virtual python environment and with MariaDb on Ubuntu 18.04.5 LTS.
I did the update from 0.118.5 to 2020.12.0 yesterday without any error, but today I restarted HA because of an update of HACS and I got this error on boot in the log file:
Error executing query: (MySQLdb._exceptions.IntegrityError) (1062, "Duplicate entry '0' for key 'PRIMARY'") in the table schema_changes
When querying this table I saw a change_id as PK and with a value 0.
The problem: the field change_id was defined as PK, but not with AUTO_INCREMENT.
So I did following manual changes to the table via the mysql cli prompt:
- log in and change to the homeassistant database: use homeassistant;
- show tables;
- show create table schema_changes;
- alter table schema_changes drop primary key;
- alter table schema_changes drop change_id;
- alter table schema_changes add change_id int(11) not null primary key auto_increment first;
After this latest command you will have again a correct filled table and a bootable HA without any error.
Is this a bug in the upgrade code when using a MySQL or MariaDb?