Keep payment methods synchronized (#1569)

This commit is contained in:
Luke Vella 2025-02-23 16:15:37 +00:00 committed by GitHub
parent 5e356afab6
commit ca46b18f3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 566 additions and 346 deletions

View file

@ -0,0 +1,14 @@
-- CreateTable
CREATE TABLE "payment_methods" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"type" TEXT NOT NULL,
"data" JSONB NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "payment_methods_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "payment_methods" ADD CONSTRAINT "payment_methods_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View file

@ -51,12 +51,13 @@ model User {
customerId String? @map("customer_id")
subscriptionId String? @unique @map("subscription_id")
comments Comment[]
polls Poll[]
watcher Watcher[]
events Event[]
accounts Account[]
participants Participant[]
comments Comment[]
polls Poll[]
watcher Watcher[]
events Event[]
accounts Account[]
participants Participant[]
paymentMethods PaymentMethod[]
subscription Subscription? @relation(fields: [subscriptionId], references: [id], onDelete: SetNull)
@ -82,6 +83,19 @@ enum SubscriptionInterval {
@@map("subscription_interval")
}
model PaymentMethod {
id String @id
userId String @map("user_id")
type String
data Json
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("payment_methods")
}
model UserPaymentData {
userId String @id @map("user_id")
subscriptionId String @map("subscription_id")