Logbook entries from pre-upgrade not showing (0.107.7 to 0.115.4)

Recorder entries created after the upgrade all show fine in the logbook.
Recorder entries that were created before the upgrade don’t show - apart from Automations(??) and the Home Assistant stopped event.

Entries are definitely present in the SQLite database. Confirmed by querying SQLite, e.g. with
SELECT entity_id,created,state,attributes FROM states WHERE entity_id LIKE '%kodi%' ORDER BY state_id DESC LIMIT 100;

Screenshot below.
Upgrade occurred after 10:36AM (after “Home Assistant stopped” event). You can see all the MQTT updates flowing in after the HA upgrade is completed and HA starts.

Relevant entries from configuration.yaml:

recorder:
  purge_keep_days: 730

history:
  exclude:
    domains:
      - automation
      - persistent_notification
      - updater
      - binary_sensor

Upgrade log:

2020-09-29 11:34:06 WARNING (MainThread) [homeassistant.components.http] The 'base_url' option is deprecated, please remove it from your configuration
2020-09-29 11:34:16 WARNING (MainThread) [homeassistant.setup] Setup of recorder is taking over 10 seconds.
2020-09-29 11:35:05 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
2020-09-29 11:35:55 WARNING (Recorder) [homeassistant.components.recorder.migration] Database is about to upgrade. Schema version: 7
2020-09-29 11:35:55 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding columns context_parent_id to table events. Note: this can take several minutes on large databases and slow computers. Please be patient!
2020-09-29 11:35:55 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding columns old_state_id to table states. Note: this can take several minutes on large databases and slow computers. Please be patient!
2020-09-29 11:35:55 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_events_context_parent_id` to database. Note: this can take several minutes on large databases and slow computers. Please be patient!
2020-09-29 11:36:05 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
2020-09-29 11:37:05 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
2020-09-29 11:37:29 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_events_event_type_time_fired` to database. Note: this can take several minutes on large databases and slow computers. Please be patient!
2020-09-29 11:38:05 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
2020-09-29 11:39:05 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder

Running in Docker on Ubuntu.
Image: homeassistant/home-assistant:stable@sha256:618a038049d7db6b858fc32d903ad95f0afe4f220fd8074ad0a9a6ba2a61f099

Anyone come across this? Any update I can apply to the database to get the logbook to show the old entries again? I’m guessing some schema update wasn’t applied which is causing these entries to be filtered out in the display…

That’s a big jump in versions.

Did you upgrade one version at a time?

There was a database optimisation in one of those intervening versions. You probably jumped right over it.

You could delete the database and restart. That would rebuild it correctly but you would lose your history.

The other option is to downgrade to 0.107 again and upgrade one version at a time.

EDIT: it was v0.112: https://www.home-assistant.io/blog/2020/07/01/release-112/#important-upgrade-notice

Judging by the log entries, I’m presuming the schema upgraded, but maybe the data updates didn’t apply?

Truncated for brevity (full entries are above)

[homeassistant.components.recorder.migration] Database is about to upgrade. Schema version: 7
[homeassistant.components.recorder.migration] Adding columns context_parent_id to table events.
[homeassistant.components.recorder.migration] Adding columns old_state_id to table states.
[homeassistant.components.recorder.migration] Adding index `ix_events_context_parent_id` to database. 
[homeassistant.components.recorder.migration] Adding index `ix_events_event_type_time_fired` to database.