Tweak DB migration to schema version 21 (#56767)

This commit is contained in:
Erik Montnemery 2021-09-29 11:25:50 +02:00 committed by GitHub
parent be34a2ddea
commit 52e9f76f94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -522,9 +522,11 @@ def _apply_update(instance, session, new_version, old_version): # noqa: C901
)
with contextlib.suppress(SQLAlchemyError):
connection.execute(
# Using LOCK=EXCLUSIVE to prevent the database from corrupting
# https://github.com/home-assistant/core/issues/56104
text(
f"ALTER TABLE {table} CONVERT TO "
"CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"
"CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci LOCK=EXCLUSIVE"
)
)
elif new_version == 22: