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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue