Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvuGvHpbAQ4syfuLuRvutL
24 lines
848 B
SQL
24 lines
848 B
SQL
-- CreateTable
|
|
CREATE TABLE "StockAlert" (
|
|
"id" TEXT NOT NULL,
|
|
"productId" TEXT NOT NULL,
|
|
"variantId" TEXT,
|
|
"email" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"notifiedAt" TIMESTAMP(3),
|
|
|
|
CONSTRAINT "StockAlert_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "StockAlert_productId_notifiedAt_idx" ON "StockAlert"("productId", "notifiedAt");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "StockAlert_email_idx" ON "StockAlert"("email");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "StockAlert" ADD CONSTRAINT "StockAlert_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "StockAlert" ADD CONSTRAINT "StockAlert_variantId_fkey" FOREIGN KEY ("variantId") REFERENCES "ProductVariant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|