mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Avoid creating a column in v8 schema that is removed in v9 schema (#37062)
This commit is contained in:
parent
cc8e0ef942
commit
255d706c24
@ -155,6 +155,11 @@ def _drop_index(engine, table_name, index_name):
|
|||||||
"Finished dropping index %s from table %s", index_name, table_name
|
"Finished dropping index %s from table %s", index_name, table_name
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
if index_name == "ix_states_context_parent_id":
|
||||||
|
# Was only there on nightly so we do not want
|
||||||
|
# to generate log noise or issues about it.
|
||||||
|
return
|
||||||
|
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Failed to drop index %s from table %s. Schema "
|
"Failed to drop index %s from table %s. Schema "
|
||||||
"Migration will continue; this is not a "
|
"Migration will continue; this is not a "
|
||||||
@ -261,9 +266,7 @@ def _apply_update(engine, new_version, old_version):
|
|||||||
_create_index(engine, "states", "ix_states_entity_id")
|
_create_index(engine, "states", "ix_states_entity_id")
|
||||||
elif new_version == 8:
|
elif new_version == 8:
|
||||||
_add_columns(engine, "events", ["context_parent_id CHARACTER(36)"])
|
_add_columns(engine, "events", ["context_parent_id CHARACTER(36)"])
|
||||||
_add_columns(engine, "states", ["context_parent_id CHARACTER(36)"])
|
|
||||||
_add_columns(engine, "states", ["old_state_id INTEGER"])
|
_add_columns(engine, "states", ["old_state_id INTEGER"])
|
||||||
_create_index(engine, "states", "ix_states_context_parent_id")
|
|
||||||
_create_index(engine, "events", "ix_events_context_parent_id")
|
_create_index(engine, "events", "ix_events_context_parent_id")
|
||||||
elif new_version == 9:
|
elif new_version == 9:
|
||||||
# We now get the context from events with a join
|
# We now get the context from events with a join
|
||||||
@ -276,6 +279,8 @@ def _apply_update(engine, new_version, old_version):
|
|||||||
#
|
#
|
||||||
_drop_index(engine, "states", "ix_states_context_id")
|
_drop_index(engine, "states", "ix_states_context_id")
|
||||||
_drop_index(engine, "states", "ix_states_context_user_id")
|
_drop_index(engine, "states", "ix_states_context_user_id")
|
||||||
|
# This index won't be there if they were not running
|
||||||
|
# nightly but we don't treat that as a critical issue
|
||||||
_drop_index(engine, "states", "ix_states_context_parent_id")
|
_drop_index(engine, "states", "ix_states_context_parent_id")
|
||||||
# Redundant keys on composite index:
|
# Redundant keys on composite index:
|
||||||
# We already have ix_states_entity_id_last_updated
|
# We already have ix_states_entity_id_last_updated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user