-- +goose Up
CREATE TABLE schedules (
    id               uuid PRIMARY KEY,
    project_id       uuid NOT NULL UNIQUE REFERENCES projects(id) ON DELETE CASCADE,
    interval_seconds int  NOT NULL DEFAULT 3600,
    enabled          boolean NOT NULL DEFAULT false,
    last_run_at      timestamptz,
    created_at       timestamptz NOT NULL DEFAULT now()
);
CREATE TABLE notification_channels (
    id         uuid PRIMARY KEY,
    project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
    type       text NOT NULL,
    config     jsonb NOT NULL,
    secret_enc text NOT NULL DEFAULT '',
    enabled    boolean NOT NULL DEFAULT true,
    created_at timestamptz NOT NULL DEFAULT now()
);
ALTER TABLE domains ADD COLUMN last_check_status text NOT NULL DEFAULT 'unknown';

-- +goose Down
ALTER TABLE domains DROP COLUMN last_check_status;
DROP TABLE notification_channels;
DROP TABLE schedules;
