Files
archie/internal/platform/pg/migrations/00008_drafts.sql
T
sam 30aa351eb6 feat(events,drafts): give sources an immutable id and a scope (#2127, #2027)
A source is keyed by a uuid, owned by the organisation or one person, and
labelled within that scope. The webhook path is a separate unique column, so
renaming either leaves stored events, event types, triggers, groups, mappings
and drafts alone. Delivery policies, sealed secrets and group keys use the id.
2026-11-24 02:43:51 +11:00

27 lines
837 B
SQL

-- +goose Up
CREATE SCHEMA drafts;
CREATE TABLE drafts.drafts (
id uuid PRIMARY KEY,
org_id text NOT NULL,
group_id uuid NOT NULL,
name text NOT NULL,
source_id uuid NOT NULL,
event_type text NOT NULL,
filter jsonb NOT NULL,
document text NOT NULL,
policy_kind text NOT NULL CHECK (policy_kind IN ('hard_rules', 'change_request')),
policy text NOT NULL,
dry_run_id uuid,
dry_event_id uuid,
installed_version integer,
published_at timestamptz,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (org_id, group_id),
UNIQUE (org_id, name)
);
-- +goose Down
DROP SCHEMA drafts CASCADE;