feat(schema): IdeaProduct junction model + relaties op Idea en Product
Voegt IdeaProduct model toe met idea_id/product_id/created_at, unique constraint op (idea_id, product_id), cascade-deletes. Breidt Product.idea_products en Idea.secondary_products relaties uit. Migratie 20260506010000_add_idea_product_secondary aangemaakt en toegepast. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d5333eb7d8
commit
9d6239b0eb
2 changed files with 41 additions and 4 deletions
|
|
@ -0,0 +1,21 @@
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "idea_products" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"idea_id" TEXT NOT NULL,
|
||||||
|
"product_id" TEXT NOT NULL,
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "idea_products_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "idea_products_product_id_idx" ON "idea_products"("product_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "idea_products_idea_id_product_id_key" ON "idea_products"("idea_id", "product_id");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "idea_products" ADD CONSTRAINT "idea_products_idea_id_fkey" FOREIGN KEY ("idea_id") REFERENCES "ideas"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "idea_products" ADD CONSTRAINT "idea_products_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "products"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
@ -188,6 +188,7 @@ model Product {
|
||||||
claude_questions ClaudeQuestion[]
|
claude_questions ClaudeQuestion[]
|
||||||
claude_jobs ClaudeJob[]
|
claude_jobs ClaudeJob[]
|
||||||
ideas Idea[]
|
ideas Idea[]
|
||||||
|
idea_products IdeaProduct[]
|
||||||
|
|
||||||
@@unique([user_id, name])
|
@@unique([user_id, name])
|
||||||
@@unique([user_id, code])
|
@@unique([user_id, code])
|
||||||
|
|
@ -416,10 +417,11 @@ model Idea {
|
||||||
created_at DateTime @default(now())
|
created_at DateTime @default(now())
|
||||||
updated_at DateTime @updatedAt
|
updated_at DateTime @updatedAt
|
||||||
|
|
||||||
questions ClaudeQuestion[]
|
questions ClaudeQuestion[]
|
||||||
jobs ClaudeJob[]
|
jobs ClaudeJob[]
|
||||||
logs IdeaLog[]
|
logs IdeaLog[]
|
||||||
user_questions UserQuestion[]
|
user_questions UserQuestion[]
|
||||||
|
secondary_products IdeaProduct[]
|
||||||
|
|
||||||
@@unique([user_id, code])
|
@@unique([user_id, code])
|
||||||
@@index([user_id, archived, status])
|
@@index([user_id, archived, status])
|
||||||
|
|
@ -427,6 +429,20 @@ model Idea {
|
||||||
@@map("ideas")
|
@@map("ideas")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model IdeaProduct {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
idea_id String
|
||||||
|
product_id String
|
||||||
|
created_at DateTime @default(now())
|
||||||
|
|
||||||
|
idea Idea @relation(fields: [idea_id], references: [id], onDelete: Cascade)
|
||||||
|
product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@unique([idea_id, product_id])
|
||||||
|
@@index([product_id])
|
||||||
|
@@map("idea_products")
|
||||||
|
}
|
||||||
|
|
||||||
model IdeaLog {
|
model IdeaLog {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
idea Idea @relation(fields: [idea_id], references: [id], onDelete: Cascade)
|
idea Idea @relation(fields: [idea_id], references: [id], onDelete: Cascade)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue