From ccb77ba1e9dd3bce22fdb01cc563a7b665918575 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 3 Jul 2020 17:35:02 -0500 Subject: [PATCH] Handle index already existing on db migration with MySQLdb backend (#37384) _create_index needed the same check as _add_columns since the MySQLdb backend throws OperationalError instead of InternalError in this case --- homeassistant/components/recorder/migration.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/recorder/migration.py b/homeassistant/components/recorder/migration.py index 1cff6d178ad..ece0e36402e 100644 --- a/homeassistant/components/recorder/migration.py +++ b/homeassistant/components/recorder/migration.py @@ -81,7 +81,9 @@ def _create_index(engine, table_name, index_name): try: index.create(engine) except OperationalError as err: - if "already exists" not in str(err).lower(): + lower_err_str = str(err).lower() + + if "already exists" not in lower_err_str and "duplicate" not in lower_err_str: raise _LOGGER.warning(