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;
