add plan_id column to recommendation table

This commit is contained in:
Daniel Roth 2026-06-05 08:12:57 +00:00
parent 57d0305a1b
commit c40e64bdec
4 changed files with 10731 additions and 0 deletions

View file

@ -0,0 +1,3 @@
ALTER TABLE "recommendation" ADD COLUMN "plan_id" bigint;--> statement-breakpoint
ALTER TABLE "recommendation" ADD CONSTRAINT "recommendation_plan_id_plan_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."plan"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "idx_recommendation_plan_id" ON "recommendation" USING btree ("plan_id");

File diff suppressed because it is too large Load diff

View file

@ -1548,6 +1548,13 @@
"when": 1780566543108,
"tag": "0221_nice_sumo",
"breakpoints": true
},
{
"idx": 222,
"version": "7",
"when": 1780647165601,
"tag": "0222_nifty_hellcat",
"breakpoints": true
}
]
}

View file

@ -67,6 +67,9 @@ export const recommendation = pgTable(
propertyId: bigint("property_id", { mode: "bigint" })
.notNull()
.references(() => property.id),
planId: bigint("plan_id", { mode: "bigint" }).references(() => plan.id, {
onDelete: "cascade",
}),
createdAt: timestamp("created_at").notNull().defaultNow(),
type: text("type").notNull(),
measureType: text("measure_type"),
@ -92,6 +95,7 @@ export const recommendation = pgTable(
},
(table) => [
index("recommendation_property_id_idx").on(table.propertyId),
index("idx_recommendation_plan_id").on(table.planId),
index("idx_recommendation_active_defaults")
.on(table.id)
.where(