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
pull/37443/head
J. Nick Koston 2020-07-03 17:35:02 -05:00 committed by Paulus Schoutsen
parent 08ebc4ce62
commit ed086e5200
1 changed files with 3 additions and 1 deletions

View File

@ -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(