mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Change character set of statistics_meta table to utf8 (#56011)
This commit is contained in:
parent
dd9bfe7aa0
commit
a47532c69b
@ -507,6 +507,17 @@ def _apply_update(engine, session, new_version, old_version): # noqa: C901
|
||||
"statistics",
|
||||
["sum_increase DOUBLE PRECISION"],
|
||||
)
|
||||
# Try to change the character set of the statistic_meta table
|
||||
if engine.dialect.name == "mysql":
|
||||
try:
|
||||
connection.execute(
|
||||
text(
|
||||
"ALTER TABLE statistics_meta CONVERT TO "
|
||||
"CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"
|
||||
)
|
||||
)
|
||||
except SQLAlchemyError:
|
||||
pass
|
||||
else:
|
||||
raise ValueError(f"No schema migration defined for version {new_version}")
|
||||
|
||||
|
@ -238,6 +238,7 @@ class Statistics(Base): # type: ignore
|
||||
__table_args__ = (
|
||||
# Used for fetching statistics for a certain entity at a specific time
|
||||
Index("ix_statistics_statistic_id_start", "metadata_id", "start"),
|
||||
{"mysql_default_charset": "utf8mb4", "mysql_collate": "utf8mb4_unicode_ci"},
|
||||
)
|
||||
__tablename__ = TABLE_STATISTICS
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user