-
Notifications
You must be signed in to change notification settings - Fork 0
x ERROR
KimJacobsen edited this page Mar 6, 2024
·
5 revisions
⛔ ERROR 1062 (23000) at line xx: Duplicate entry
💡 If you have dublicated data, you have to fix it else this wont work.
###############################################################################################
Remember to change back to UNIQUE after data import is finish and delete the duplicate entries. Dont activate MariaDB in homeassistant before you have Import the data and delete the duplicate entries change back to UNIQUE, then import the last file to complete the merge.
###############################################################################################
ALTER TABLE `homeassistant`.`states` DROP INDEX `ix_states_metadata_id_last_updated_ts`, ADD INDEX `ix_states_metadata_id_last_updated_ts` (`metadata_id`, `last_updated_ts`) USING BTREE;
Import the data and delete the duplicate entries then run
ALTER TABLE `homeassistant`.`states` DROP INDEX `ix_states_metadata_id_last_updated_ts`, ADD UNIQUE `ix_states_metadata_id_last_updated_ts` (`metadata_id`, `last_updated_ts`) USING BTREE;
# ERROR 1062 (23000) at line 10: Duplicate entry '0-0' for key 'ix_statistics_short_term_statistic_id_start_ts'
ALTER TABLE `homeassistant`.`statistics_short_term` DROP INDEX `ix_statistics_short_term_statistic_id_start_ts`, ADD INDEX `ix_statistics_short_term_statistic_id_start_ts` (`metadata_id`, `start_ts`) USING BTREE;
Import the data and delete the duplicate entries then run
ALTER TABLE `homeassistant`.`statistics_short_term` DROP INDEX `ix_statistics_short_term_statistic_id_start_ts`, ADD UNIQUE `ix_statistics_short_term_statistic_id_start_ts` (`metadata_id`, `start_ts`) USING BTREE;
# ERROR 1062 (23000) at line 14187: Duplicate entry '0-0' for key 'ix_statistics_statistic_id_start_ts'
ALTER TABLE `homeassistant`.`statistics` DROP INDEX `ix_statistics_statistic_id_start_ts`, ADD INDEX `ix_statistics_statistic_id_start_ts` (`metadata_id`, `start_ts`) USING BTREE;
Import the data and delete the duplicate entries then run
ALTER TABLE `homeassistant`.`statistics` DROP INDEX `ix_statistics_statistic_id_start_ts`, ADD UNIQUE `ix_statistics_statistic_id_start_ts` (`metadata_id`, `start_ts`) USING BTREE;
⛑️ How2 fix the duplicated data 🙅