Store idempotent event outcomes and an only-forward shadow without replacing plan SSOT. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.4 KiB
SQL
42 lines
1.4 KiB
SQL
-- +goose Up
|
|
-- U4: idempotent projection outcomes and only-forward plan shadow. Cards/SSE read shadow; PG plans remain SSOT.
|
|
|
|
CREATE TABLE IF NOT EXISTS intent_plan_projections (
|
|
source_event_id TEXT PRIMARY KEY,
|
|
plan_id TEXT NOT NULL,
|
|
revision BIGINT NOT NULL,
|
|
status TEXT NOT NULL,
|
|
step_id TEXT NOT NULL DEFAULT '',
|
|
environment TEXT NOT NULL,
|
|
project_id BIGINT NOT NULL,
|
|
user_id BIGINT NOT NULL,
|
|
session_id TEXT NOT NULL,
|
|
summary_ref TEXT NOT NULL DEFAULT '',
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_intent_plan_projections_plan
|
|
ON intent_plan_projections (plan_id, revision);
|
|
|
|
CREATE TABLE IF NOT EXISTS intent_plan_shadow (
|
|
plan_id TEXT PRIMARY KEY,
|
|
revision BIGINT NOT NULL,
|
|
status TEXT NOT NULL,
|
|
step_id TEXT NOT NULL DEFAULT '',
|
|
environment TEXT NOT NULL,
|
|
project_id BIGINT NOT NULL,
|
|
user_id BIGINT NOT NULL,
|
|
session_id TEXT NOT NULL,
|
|
summary_ref TEXT NOT NULL DEFAULT '',
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_intent_plan_shadow_scope
|
|
ON intent_plan_shadow (environment, project_id, session_id, user_id);
|
|
|
|
-- +goose Down
|
|
DROP INDEX IF EXISTS idx_intent_plan_shadow_scope;
|
|
DROP TABLE IF EXISTS intent_plan_shadow;
|
|
DROP INDEX IF EXISTS idx_intent_plan_projections_plan;
|
|
DROP TABLE IF EXISTS intent_plan_projections;
|