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
This commit is contained in:
J. Nick Koston 2020-07-03 17:35:02 -05:00 committed by GitHub
parent 7da3065de6
commit ccb77ba1e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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(