#db migrations do not work from a new DB

1 messages · Page 1 of 1 (latest)

unique patrol
#

With the most recent upgrade, something went wrong with the database migrations for recorder, I then dumped my whole db, not overally fussed and now it can not create .

sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (3780, "Referencing column 'metadata_id' and referenced column 'id' in foreign key constraint 'statistics_short_term_ibfk_1' are incompatible.")
[SQL:
CREATE TABLE statistics_short_term (
    metadata_id INTEGER,
    id BIGINT NOT NULL AUTO_INCREMENT,
    created CHAR(0),
    created_ts DOUBLE,
    start CHAR(0),
    start_ts DOUBLE,
    mean DOUBLE,
    mean_weight DOUBLE,
    min DOUBLE,
    max DOUBLE,
    last_reset CHAR(0),
    last_reset_ts DOUBLE,
    state DOUBLE,
    sum DOUBLE,
    PRIMARY KEY (id),
    FOREIGN KEY(metadata_id) REFERENCES statistics_meta (id) ON DELETE CASCADE
)DEFAULT CHARSET=utf8mb4 ENGINE=InnoDB COLLATE utf8mb4_unicode_ci

]

new db from sratch, recorder still can not work, I have tried many times, it gets this far;

MySQL [hass]> show tables;
+-------------------+
| Tables_in_hass    |
+-------------------+
| event_data        |
| event_types       |
| events            |
| migration_changes |
| recorder_runs     |
| schema_changes    |
| state_attributes  |
| states            |
| states_meta       |
| statistics_meta   |
| statistics_runs   |
+-------------------+
11 rows in set (0.003 sec)
#
MySQL [hass]> select * from migration_changes;
Empty set (0.001 sec)

MySQL [hass]> select * from schema_changes;
Empty set (0.005 sec)
#

mysqld (mysqld 8.4.3) starting as process 1

#

looks like it isn't you, its me. 😉 Probably didn't need to drop my db after all of that. oh, well.

unique patrol
#

not sure how to tag this as resolved, sorry