CREATE TABLE database_releases (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    version TEXT NOT NULL UNIQUE,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    schema_version INTEGER NOT NULL DEFAULT 0,
    update_interval TEXT NOT NULL DEFAULT '168h',
    dump_file_name TEXT,
    dump_sha256 TEXT,
    dump_size_bytes BIGINT,
    source_summary JSONB NOT NULL DEFAULT '{}'::jsonb,
    is_current BOOLEAN NOT NULL DEFAULT false
);

CREATE UNIQUE INDEX database_releases_one_current_idx
    ON database_releases (is_current)
    WHERE is_current = true;

