39 lines
1.4 KiB
SQL
39 lines
1.4 KiB
SQL
-- S01只保存命令、审阅、决定与影响;业务实例表由各owner迁移定义。
|
||
CREATE TABLE public.muse_change_command (
|
||
author_id text NOT NULL,
|
||
run_purpose public.muse_purpose NOT NULL CHECK (run_purpose='production'),
|
||
command_id text NOT NULL,
|
||
request_hash text NOT NULL,
|
||
receipt jsonb,
|
||
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||
PRIMARY KEY(author_id,run_purpose,command_id)
|
||
);
|
||
CREATE TABLE public.muse_author_review (
|
||
review_id uuid PRIMARY KEY,
|
||
author_id text NOT NULL,
|
||
entry_id text NOT NULL,
|
||
target_ref text NOT NULL,
|
||
content_hash text NOT NULL,
|
||
snapshot jsonb NOT NULL,
|
||
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
|
||
);
|
||
CREATE TABLE public.muse_candidate_decision (
|
||
candidate_id text NOT NULL,
|
||
candidate_revision bigint NOT NULL,
|
||
decision text NOT NULL CHECK (decision IN ('adopt','reject','defer')),
|
||
author_id text NOT NULL,
|
||
review_id uuid NOT NULL REFERENCES public.muse_author_review(review_id),
|
||
command_id text NOT NULL,
|
||
PRIMARY KEY(candidate_id,candidate_revision)
|
||
);
|
||
CREATE TABLE public.muse_change_impact (
|
||
impact_id uuid PRIMARY KEY,
|
||
receipt_id uuid NOT NULL,
|
||
target_ref text NOT NULL,
|
||
reason text NOT NULL,
|
||
before_version text NOT NULL,
|
||
after_version text NOT NULL,
|
||
state text NOT NULL DEFAULT 'pending' CHECK (state IN ('pending','handled')),
|
||
UNIQUE(receipt_id,target_ref,reason)
|
||
);
|