Files
roast_command_center/db/migrations/014_plan_revisions.sql
T
snowspeeder 8c21750356
Test and deploy / test-and-deploy (push) Successful in 1m21s
Build coffee history and experiment workflows with Ask Bean Bro
2026-09-06 18:43:33 -04:00

13 lines
626 B
SQL

CREATE TABLE plan_revisions (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
plan_id uuid NOT NULL REFERENCES roast_plans(id) ON DELETE CASCADE,
plan jsonb NOT NULL,
name text NOT NULL DEFAULT '',
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX plan_revisions_plan ON plan_revisions(user_id, plan_id, created_at DESC);
ALTER TABLE actual_roasts ADD COLUMN IF NOT EXISTS manual_key text;
CREATE UNIQUE INDEX actual_roasts_manual_once ON actual_roasts(user_id, manual_key);
ALTER TABLE actual_roasts ADD COLUMN IF NOT EXISTS plan_snapshot jsonb;