feat(pg): tables for stored workflow documents, dry runs and drafts (#2008)
This commit is contained in:
2 files changed
+55
No files matched your search
@@ -0,0 +1,55 @@
|
||||
-- +goose Up
|
||||
-- A workflow is a document, stored by name and version. A run pins the version
|
||||
-- it started on and executes that document.
|
||||
CREATE TABLE runs.workflows (
|
||||
org_id text NOT NULL,
|
||||
name text NOT NULL,
|
||||
version integer NOT NULL,
|
||||
body text NOT NULL,
|
||||
created_by text NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (org_id, name, version)
|
||||
);
|
||||
|
||||
-- A dry run judges every action and executes none that changes something. It
|
||||
-- carries the unpublished document and policy it runs under in overlay, and
|
||||
-- pins no stored version.
|
||||
ALTER TABLE runs.runs
|
||||
ADD COLUMN dry boolean NOT NULL DEFAULT false,
|
||||
ADD COLUMN overlay jsonb;
|
||||
|
||||
-- A dry run's decisions are kept for its trail and counted toward nothing:
|
||||
-- not the action budget, not a class's history.
|
||||
ALTER TABLE judgement.decisions ADD COLUMN dry boolean NOT NULL DEFAULT false;
|
||||
|
||||
-- A draft bundles the trigger an unmatched group proposes, the workflow that
|
||||
-- trigger would start and any policy it needs, with the dry run last made of
|
||||
-- it. One draft per group.
|
||||
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 text 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;
|
||||
ALTER TABLE judgement.decisions DROP COLUMN dry;
|
||||
ALTER TABLE runs.runs DROP COLUMN overlay, DROP COLUMN dry;
|
||||
DROP TABLE runs.workflows;
|
||||
File renamed without changes.
Reference in new issue
Block a user