manicanldes-backend/prisma/migrations/20261005120000_private_wish.../migration.sql

23 lines
1.1 KiB
SQL

-- CreateTable
CREATE TABLE "wishlist_items" (
"id" UUID NOT NULL,
"organization_id" UUID NOT NULL,
"user_id" UUID NOT NULL,
"variant_id" UUID NOT NULL,
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "wishlist_items_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "wishlist_items_user_id_organization_id_created_at_id_idx" ON "wishlist_items"("user_id", "organization_id", "created_at", "id");
-- CreateIndex
CREATE UNIQUE INDEX "wishlist_items_user_id_organization_id_variant_id_key" ON "wishlist_items"("user_id", "organization_id", "variant_id");
-- AddForeignKey
ALTER TABLE "wishlist_items" ADD CONSTRAINT "wishlist_items_user_id_organization_id_fkey" FOREIGN KEY ("user_id", "organization_id") REFERENCES "users"("id", "organization_id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "wishlist_items" ADD CONSTRAINT "wishlist_items_variant_id_organization_id_fkey" FOREIGN KEY ("variant_id", "organization_id") REFERENCES "product_variants"("id", "organization_id") ON DELETE RESTRICT ON UPDATE CASCADE;