fix(migration): make trigger creation idempotent with DROP IF EXISTS
Previous failed runs committed the CREATE TABLE/TRIGGER DDL outside a transaction (pool.query BEGIN/ROLLBACK is not connection-pinned), leaving the trigger in place. Re-runs then fail with 'already exists'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,9 @@ CREATE INDEX IF NOT EXISTS idx_persoenliche_ausruestung_artikel
|
|||||||
ON persoenliche_ausruestung(artikel_id);
|
ON persoenliche_ausruestung(artikel_id);
|
||||||
|
|
||||||
-- Auto-update aktualisiert_am trigger (uses the aktualisiert_am variant from migration 018)
|
-- Auto-update aktualisiert_am trigger (uses the aktualisiert_am variant from migration 018)
|
||||||
|
-- DROP first to make this idempotent — previous failed migration runs may have committed the DDL
|
||||||
|
-- without recording the migration (pool.query BEGIN/ROLLBACK does not guarantee same connection).
|
||||||
|
DROP TRIGGER IF EXISTS trg_persoenliche_ausruestung_aktualisiert_am ON persoenliche_ausruestung;
|
||||||
CREATE TRIGGER trg_persoenliche_ausruestung_aktualisiert_am
|
CREATE TRIGGER trg_persoenliche_ausruestung_aktualisiert_am
|
||||||
BEFORE UPDATE ON persoenliche_ausruestung
|
BEFORE UPDATE ON persoenliche_ausruestung
|
||||||
FOR EACH ROW EXECUTE FUNCTION update_aktualisiert_am_column();
|
FOR EACH ROW EXECUTE FUNCTION update_aktualisiert_am_column();
|
||||||
|
|||||||
Reference in New Issue
Block a user