Double underscore error in history screen after update

Hi I’m updated haas from 0.7x to 0.91 and encountered same issue as described here:
https://github.com/home-assistant/home-assistant/issues/20371

I can’t load logbook screen, my trace ends with:
"Format should be <domain>.<object_id>").format(entity_id)) homeassistant.exceptions.InvalidEntityFormatError: Invalid entity id encountered: automation.button_long_press__all_lights_off. Format should be <domain>.<object_id>

How do I deal with that?
ps: On top of all my sensors and buttons not triggering automatons anymore. But it seems that I have to fix the logbook screen first.

As said here https://github.com/home-assistant/home-assistant/pull/20367 - I can fix this issue changing IDs with SQL in the database. But I have no idea how to connect there.

Fixed by using this doc https://www.home-assistant.io/docs/backend/database/
and manually running sql’s like that:

UPDATE states
SET entity_id = 'sensor.netatmo_outdoor_ox_humidity'
WHERE entity_id = 'sensor.netatmo_outdoor__ox_humidity';

upd: Nope, sorry. The problem was still there, so I ended up deleting database. That helped with the logbook.