@cat-factory/node-server 0.124.0 → 0.125.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ -- Self-healing before constraining (mirror of D1 migration 0066): a deployment that already ran
2
+ -- the delete-then-insert publish path can hold duplicate live reviews for one block, and
3
+ -- CREATE UNIQUE INDEX would hard-fail on them. Delete every row that has a strictly newer sibling
4
+ -- in its group, so exactly the row `getByBlock` returns today survives — the review the product is
5
+ -- already showing. The superseded duplicates were never reachable.
6
+ DELETE FROM "requirement_reviews" a
7
+ USING "requirement_reviews" b
8
+ WHERE a.workspace_id = b.workspace_id
9
+ AND a.block_id = b.block_id
10
+ AND (b.created_at, b.id) > (a.created_at, a.id);
11
+ --> statement-breakpoint
12
+ DELETE FROM "clarity_reviews" a
13
+ USING "clarity_reviews" b
14
+ WHERE a.workspace_id = b.workspace_id
15
+ AND a.block_id = b.block_id
16
+ AND (b.created_at, b.id) > (a.created_at, a.id);
17
+ --> statement-breakpoint
18
+ -- Brainstorm is keyed by (block, STAGE): a block legitimately holds one live `requirements` and
19
+ -- one live `architecture` session at once, so the stage is part of the uniqueness key.
20
+ DELETE FROM "brainstorm_sessions" a
21
+ USING "brainstorm_sessions" b
22
+ WHERE a.workspace_id = b.workspace_id
23
+ AND a.block_id = b.block_id
24
+ AND a.stage = b.stage
25
+ AND (b.created_at, b.id) > (a.created_at, a.id);
26
+ --> statement-breakpoint
27
+ DROP INDEX "idx_brainstorm_sessions_block_stage";--> statement-breakpoint
28
+ CREATE UNIQUE INDEX "idx_brainstorm_sessions_block_stage" ON "brainstorm_sessions" ("workspace_id","block_id","stage");--> statement-breakpoint
29
+ DROP INDEX "idx_clarity_reviews_block";--> statement-breakpoint
30
+ CREATE UNIQUE INDEX "idx_clarity_reviews_block" ON "clarity_reviews" ("workspace_id","block_id");--> statement-breakpoint
31
+ DROP INDEX "idx_requirement_reviews_block";--> statement-breakpoint
32
+ CREATE UNIQUE INDEX "idx_requirement_reviews_block" ON "requirement_reviews" ("workspace_id","block_id");