Better migration locking behaviour

This commit is contained in:
2019-10-22 13:41:21 +02:00
parent 5aced1b8b1
commit 6ab4c1e4d3
6 changed files with 32 additions and 2 deletions

View File

@@ -2,4 +2,12 @@ CREATE TABLE IF NOT EXISTS migrations (
id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name text UNIQUE NOT NULL,
applied_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP
)
);
CREATE TABLE IF NOT EXISTS migrations_lock (
id integer PRIMARY KEY,
is_locked boolean NOT NULL DEFAULT false
);
INSERT INTO migrations_lock (id, is_locked) VALUES (1, false)
ON CONFLICT DO NOTHING;