muse-agent-example/数据库/迁移/V0003__正式变更.sql
zizi a6f4f14a81 W09 正式变更、审阅、CAS 与原子提交:S01 正式变更、作者审阅、CAS 并发与跨模块原子提交。
按 R2 串行阶段整理提交;包内文件为该阶段交付(含后续小增量),状态以工作包清单为准。
2026-09-10 19:25:41 +08:00

39 lines
1.4 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 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)
);