From bf63e6cbd40baa287add85cfe9adb06df162a4ec Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 19 Mar 2023 16:30:01 -1000 Subject: [PATCH] Set unique on StatesMeta and EventTypes database tables (#89971) Set unique on StatesMeta and EventTypes These should have been marked unique originally to prevent collision bugs from going unnoticed. These have not been to beta yet so this is not a breaking change --- homeassistant/components/recorder/db_schema.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/recorder/db_schema.py b/homeassistant/components/recorder/db_schema.py index 4826453e4c8..0bb0b846a3f 100644 --- a/homeassistant/components/recorder/db_schema.py +++ b/homeassistant/components/recorder/db_schema.py @@ -350,7 +350,7 @@ class EventTypes(Base): __tablename__ = TABLE_EVENT_TYPES event_type_id: Mapped[int] = mapped_column(Integer, Identity(), primary_key=True) event_type: Mapped[str | None] = mapped_column( - String(MAX_LENGTH_EVENT_EVENT_TYPE), index=True + String(MAX_LENGTH_EVENT_EVENT_TYPE), index=True, unique=True ) def __repr__(self) -> str: @@ -600,7 +600,7 @@ class StatesMeta(Base): __tablename__ = TABLE_STATES_META metadata_id: Mapped[int] = mapped_column(Integer, Identity(), primary_key=True) entity_id: Mapped[str | None] = mapped_column( - String(MAX_LENGTH_STATE_ENTITY_ID), index=True + String(MAX_LENGTH_STATE_ENTITY_ID), index=True, unique=True ) def __repr__(self) -> str: