feat: add Payment model for yookassa integration
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Payment" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"orderId" TEXT NOT NULL,
|
||||
"yookassaPaymentId" TEXT NOT NULL,
|
||||
"status" TEXT NOT NULL,
|
||||
"amountCents" INTEGER NOT NULL,
|
||||
"currency" TEXT NOT NULL DEFAULT 'RUB',
|
||||
"confirmationUrl" TEXT,
|
||||
"expiresAt" DATETIME,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
CONSTRAINT "Payment_orderId_fkey" FOREIGN KEY ("orderId") REFERENCES "Order" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Payment_yookassaPaymentId_key" ON "Payment"("yookassaPaymentId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Payment_orderId_idx" ON "Payment"("orderId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Payment_yookassaPaymentId_idx" ON "Payment"("yookassaPaymentId");
|
||||
@@ -153,12 +153,30 @@ model Order {
|
||||
|
||||
items OrderItem[]
|
||||
messages OrderMessage[]
|
||||
payments Payment[]
|
||||
messageReadStates UserOrderMessageReadState[]
|
||||
|
||||
@@index([userId, createdAt])
|
||||
@@index([status, updatedAt])
|
||||
}
|
||||
|
||||
model Payment {
|
||||
id String @id @default(cuid())
|
||||
orderId String
|
||||
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
|
||||
yookassaPaymentId String @unique
|
||||
status String
|
||||
amountCents Int
|
||||
currency String @default("RUB")
|
||||
confirmationUrl String?
|
||||
expiresAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([orderId])
|
||||
@@index([yookassaPaymentId])
|
||||
}
|
||||
|
||||
model OrderItem {
|
||||
id String @id @default(cuid())
|
||||
qty Int
|
||||
|
||||
Reference in New Issue
Block a user