💳 Support payments with Stripe (#822)

This commit is contained in:
Luke Vella 2023-08-23 15:29:40 +01:00 committed by GitHub
parent 969ae35971
commit 6f425edeaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 712 additions and 229 deletions

View file

@ -0,0 +1,27 @@
/*
Warnings:
- A unique constraint covering the columns `[subscription_id]` on the table `users` will be added. If there are existing duplicate values, this will fail.
*/
-- AlterTable
ALTER TABLE "users" ADD COLUMN "customer_id" TEXT,
ADD COLUMN "subscription_id" TEXT;
-- CreateTable
CREATE TABLE "subscriptions" (
"id" TEXT NOT NULL,
"price_id" TEXT NOT NULL,
"active" BOOLEAN NOT NULL,
"currency" TEXT,
"interval" TEXT,
"interval_count" INTEGER,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"period_start" TIMESTAMP(3) NOT NULL,
"period_end" TIMESTAMP(3) NOT NULL,
CONSTRAINT "subscriptions_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "users_subscription_id_key" ON "users"("subscription_id");

View file

@ -17,15 +17,18 @@ enum TimeFormat {
}
model User {
id String @id @default(cuid())
name String
email String @unique() @db.Citext
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt @map("updated_at")
comments Comment[]
polls Poll[]
watcher Watcher[]
events Event[]
id String @id @default(cuid())
name String
email String @unique() @db.Citext
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt @map("updated_at")
comments Comment[]
polls Poll[]
watcher Watcher[]
events Event[]
customerId String? @map("customer_id")
subscription Subscription? @relation(fields: [subscriptionId], references: [id])
subscriptionId String? @unique @map("subscription_id")
@@map("users")
}
@ -52,6 +55,21 @@ model UserPaymentData {
@@map("user_payment_data")
}
model Subscription {
id String @id
priceId String @map("price_id")
active Boolean
currency String?
interval String?
intervalCount Int? @map("interval_count")
createdAt DateTime @default(now()) @map("created_at")
periodStart DateTime @map("period_start")
periodEnd DateTime @map("period_end")
user User?
@@map("subscriptions")
}
model UserPreferences {
userId String @id @map("user_id")
timeZone String? @map("time_zone")