Files
buzz-sheet/drizzle/0037_right_rockslide.sql
gunshiz fcf6a2c187
CI / Build immutable images and deploy (push) Has been cancelled
CI / Verify (push) Has been cancelled
feat(guides) : add selectable target and team conditions
2026-09-06 17:40:06 +07:00

16 lines
1.5 KiB
SQL

CREATE TABLE "guides"."team_condition" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"guide_id" uuid NOT NULL,
"note" text,
"sort_order" integer DEFAULT 0 NOT NULL
);
--> statement-breakpoint
ALTER TABLE "guides"."artifact_profile" ADD COLUMN "target_conditions" jsonb DEFAULT '[]'::jsonb NOT NULL;--> statement-breakpoint
ALTER TABLE "guides"."team_composition" ADD COLUMN "condition_id" uuid;--> statement-breakpoint
UPDATE "guides"."artifact_profile" SET "target_conditions" = jsonb_build_array(jsonb_build_object('note', NULL, 'rows', "targets"));--> statement-breakpoint
INSERT INTO "guides"."team_condition" ("guide_id", "sort_order") SELECT DISTINCT "guide_id", 0 FROM "guides"."team_composition";--> statement-breakpoint
UPDATE "guides"."team_composition" AS team SET "condition_id" = condition."id" FROM "guides"."team_condition" AS condition WHERE condition."guide_id" = team."guide_id";--> statement-breakpoint
ALTER TABLE "guides"."team_condition" ADD CONSTRAINT "team_condition_guide_id_guide_id_fk" FOREIGN KEY ("guide_id") REFERENCES "guides"."guide"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "team_condition_order_idx" ON "guides"."team_condition" USING btree ("guide_id","sort_order");--> statement-breakpoint
ALTER TABLE "guides"."team_composition" ADD CONSTRAINT "team_composition_condition_id_team_condition_id_fk" FOREIGN KEY ("condition_id") REFERENCES "guides"."team_condition"("id") ON DELETE cascade ON UPDATE no action;