mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Improve recorder migration for PostgreSQL when columns already exist (#65680)
This commit is contained in:
parent
9cd6bb7335
commit
ea1245f308
@ -104,7 +104,7 @@ def _create_index(instance, table_name, index_name):
|
|||||||
with session_scope(session=instance.get_session()) as session:
|
with session_scope(session=instance.get_session()) as session:
|
||||||
connection = session.connection()
|
connection = session.connection()
|
||||||
index.create(connection)
|
index.create(connection)
|
||||||
except (InternalError, ProgrammingError, OperationalError) as err:
|
except (InternalError, OperationalError, ProgrammingError) as err:
|
||||||
raise_if_exception_missing_str(err, ["already exists", "duplicate"])
|
raise_if_exception_missing_str(err, ["already exists", "duplicate"])
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Index %s already exists on %s, continuing", index_name, table_name
|
"Index %s already exists on %s, continuing", index_name, table_name
|
||||||
@ -213,7 +213,7 @@ def _add_columns(instance, table_name, columns_def):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except (InternalError, OperationalError):
|
except (InternalError, OperationalError, ProgrammingError):
|
||||||
# Some engines support adding all columns at once,
|
# Some engines support adding all columns at once,
|
||||||
# this error is when they don't
|
# this error is when they don't
|
||||||
_LOGGER.info("Unable to use quick column add. Adding 1 by 1")
|
_LOGGER.info("Unable to use quick column add. Adding 1 by 1")
|
||||||
@ -229,7 +229,7 @@ def _add_columns(instance, table_name, columns_def):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except (InternalError, OperationalError) as err:
|
except (InternalError, OperationalError, ProgrammingError) as err:
|
||||||
raise_if_exception_missing_str(err, ["already exists", "duplicate"])
|
raise_if_exception_missing_str(err, ["already exists", "duplicate"])
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Column %s already exists on %s, continuing",
|
"Column %s already exists on %s, continuing",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user