added card creation and booking functionality

This commit is contained in:
Rajpreet0 2026-10-02 14:30:54 +02:00
parent 86330af16e
commit 7aa887c5aa
85 changed files with 7434 additions and 314 deletions

View file

@ -0,0 +1,23 @@
-- CreateTable
CREATE TABLE "Product" (
"id" TEXT NOT NULL,
"businessId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
"credits" INTEGER NOT NULL,
"priceCents" INTEGER NOT NULL,
"validityMonths" INTEGER,
"sports" TEXT[],
"design" JSONB NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Product_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "Product_businessId_idx" ON "Product"("businessId");
-- AddForeignKey
ALTER TABLE "Product" ADD CONSTRAINT "Product_businessId_fkey" FOREIGN KEY ("businessId") REFERENCES "Business"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View file

@ -0,0 +1,92 @@
-- AlterTable
ALTER TABLE "CourseBooking" ADD COLUMN "passId" TEXT;
-- CreateTable
CREATE TABLE "CustomerPass" (
"id" TEXT NOT NULL,
"productId" TEXT NOT NULL,
"businessId" TEXT NOT NULL,
"userId" TEXT,
"email" TEXT NOT NULL,
"name" TEXT NOT NULL,
"sports" TEXT[],
"creditsTotal" INTEGER NOT NULL,
"creditsRemaining" INTEGER NOT NULL,
"validUntil" TIMESTAMP(3),
"status" TEXT NOT NULL DEFAULT 'active',
"source" TEXT NOT NULL,
"priceCents" INTEGER,
"stripeAccountId" TEXT,
"stripeSessionId" TEXT,
"stripePaymentIntentId" TEXT,
"amountPaid" INTEGER,
"platformFee" INTEGER,
"stripeFee" INTEGER,
"billingAddress" JSONB,
"invoiceNumber" TEXT,
"invoiceIssuedAt" TIMESTAMP(3),
"refundedAmount" INTEGER,
"refundedAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "CustomerPass_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "PassAdjustment" (
"id" TEXT NOT NULL,
"passId" TEXT NOT NULL,
"managerId" TEXT NOT NULL,
"type" TEXT NOT NULL,
"creditsDelta" INTEGER,
"previousValidUntil" TIMESTAMP(3),
"newValidUntil" TIMESTAMP(3),
"reason" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "PassAdjustment_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "CustomerPass_stripeSessionId_key" ON "CustomerPass"("stripeSessionId");
-- CreateIndex
CREATE UNIQUE INDEX "CustomerPass_stripePaymentIntentId_key" ON "CustomerPass"("stripePaymentIntentId");
-- CreateIndex
CREATE UNIQUE INDEX "CustomerPass_invoiceNumber_key" ON "CustomerPass"("invoiceNumber");
-- CreateIndex
CREATE INDEX "CustomerPass_businessId_idx" ON "CustomerPass"("businessId");
-- CreateIndex
CREATE INDEX "CustomerPass_userId_idx" ON "CustomerPass"("userId");
-- CreateIndex
CREATE INDEX "CustomerPass_email_idx" ON "CustomerPass"("email");
-- CreateIndex
CREATE INDEX "CustomerPass_productId_idx" ON "CustomerPass"("productId");
-- CreateIndex
CREATE INDEX "PassAdjustment_passId_idx" ON "PassAdjustment"("passId");
-- CreateIndex
CREATE INDEX "CourseBooking_passId_idx" ON "CourseBooking"("passId");
-- AddForeignKey
ALTER TABLE "CourseBooking" ADD CONSTRAINT "CourseBooking_passId_fkey" FOREIGN KEY ("passId") REFERENCES "CustomerPass"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "CustomerPass" ADD CONSTRAINT "CustomerPass_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE NO ACTION ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "CustomerPass" ADD CONSTRAINT "CustomerPass_businessId_fkey" FOREIGN KEY ("businessId") REFERENCES "Business"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "CustomerPass" ADD CONSTRAINT "CustomerPass_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PassAdjustment" ADD CONSTRAINT "PassAdjustment_passId_fkey" FOREIGN KEY ("passId") REFERENCES "CustomerPass"("id") ON DELETE CASCADE ON UPDATE CASCADE;