mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Raise on database error in recorder.migration._add_constraint (#123646)
* Raise on database error in recorder.migration._add_constraint * Fix test
This commit is contained in:
parent
b698dd8f32
commit
80f5683cd6
@ -727,6 +727,7 @@ def _add_constraint(
|
||||
connection.execute(add_constraint)
|
||||
except (InternalError, OperationalError):
|
||||
_LOGGER.exception("Could not update foreign options in %s table", table)
|
||||
raise
|
||||
|
||||
|
||||
def _delete_foreign_key_violations(
|
||||
|
@ -962,9 +962,10 @@ def test_restore_foreign_key_constraints_with_error(
|
||||
engine = Mock()
|
||||
|
||||
session_maker = Mock(return_value=session)
|
||||
migration._restore_foreign_key_constraints(
|
||||
session_maker, engine, constraints_to_restore
|
||||
)
|
||||
with pytest.raises(InternalError):
|
||||
migration._restore_foreign_key_constraints(
|
||||
session_maker, engine, constraints_to_restore
|
||||
)
|
||||
|
||||
assert "Could not update foreign options in events table" in caplog.text
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user