Haha, yeah, I just tried to remove some bogus records myself and ran into the same problem.
we probably got some added functionality with the old_state_id
reference but now we cannot remove data – seemingly without wiping the whole entity_id
's record. I tried to do all datapoints in one delete query but it still failed with the foreign key error.
Input:
delete from states where entity_id='sensor.living_room_eco2_value';
Output:
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (
hassio_db.
states, CONSTRAINT
states_ibfk_2 FOREIGN KEY (
old_state_id) REFERENCES
states (
state_id) ON DELETE NO ACTION)