-- Both tables are created by every replica at startup, so every statement is IF NOT EXISTS.
-- The shedlock table's shape is fixed by ShedLock: name, lock_until, locked_at, locked_by.
-- lock_until and locked_at must be timestamps; with usingDbTime() they are written by the
-- database, so their precision and time zone are the database's, not the JVM's.
create table if not exists shedlock (
    name       varchar(64)  not null,
    lock_until timestamp    not null,
    locked_at  timestamp    not null,
    locked_by  varchar(255) not null,
    primary key (name)
);

create table if not exists job_execution (
    id          serial primary key,
    job_name    varchar(64)  not null,
    instance_id varchar(64)  not null,
    started_at  timestamp    not null
);
