fix: initialise new terraform state to avoid NOT NULL constraint violation

This commit is contained in:
Iain Learmonth 2024-11-29 15:36:50 +00:00
parent 0b3254f99c
commit b91e078e22

View file

@ -42,7 +42,7 @@ def handle_update(key: str) -> ResponseReturnValue:
def handle_lock(key: str) -> ResponseReturnValue: def handle_lock(key: str) -> ResponseReturnValue:
state = TerraformState.query.filter(TerraformState.key == key).with_for_update().first() state = TerraformState.query.filter(TerraformState.key == key).with_for_update().first()
if state is None: if state is None:
state = TerraformState(key=key) state = TerraformState(key=key, state="")
db.session.add(state) db.session.add(state)
if state.lock is not None: if state.lock is not None:
lock = state.lock lock = state.lock