13 lines
626 B
SQL
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;
|