Added portfolioId to plan

This commit is contained in:
Khalim Conn-Kowlessar 2023-08-11 11:12:41 +01:00
parent 5ebcea2ab0
commit 5e881f256a
4 changed files with 1251 additions and 0 deletions

View file

@ -0,0 +1,6 @@
ALTER TABLE "plan" ADD COLUMN "portfolio_id" bigint NOT NULL;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "plan" ADD CONSTRAINT "plan_portfolio_id_portfolio_id_fk" FOREIGN KEY ("portfolio_id") REFERENCES "portfolio"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

File diff suppressed because it is too large Load diff

View file

@ -190,6 +190,13 @@
"when": 1691685306098,
"tag": "0026_blue_randall",
"breakpoints": true
},
{
"idx": 27,
"version": "5",
"when": 1691748727401,
"tag": "0027_shocking_scrambler",
"breakpoints": true
}
]
}

View file

@ -1,4 +1,5 @@
import { property } from "./property";
import { portfolio } from "./portfolio";
import {
bigserial,
text,
@ -63,6 +64,9 @@ export const recommendationMaterials = pgTable("recommendation_materials", {
export const plan = pgTable("plan", {
id: bigserial("id", { mode: "bigint" }).primaryKey(),
portfolioId: bigint("portfolio_id", { mode: "bigint" })
.notNull()
.references(() => portfolio.id),
createdAt: timestamp("created_at").notNull().defaultNow(),
isDefault: boolean("is_default").notNull(),
});