Order api: create order schema

This commit is contained in:
Md Sharafat Hassain
2026-04-12 22:47:56 +06:00
parent 308445f346
commit ee5eb0f0f5
20 changed files with 443 additions and 33 deletions
@@ -0,0 +1,27 @@
-- CreateEnum
CREATE TYPE "STATUS" AS ENUM ('INITIATED', 'CONFIRMED', 'ONGOING', 'DELIVERED', 'CANCELLED');
-- CreateEnum
CREATE TYPE "PAYMENT_TYPE" AS ENUM ('COD');
-- CreateTable
CREATE TABLE "Order" (
"id" TEXT NOT NULL,
"shopAccountId" TEXT NOT NULL,
"productPrice" INTEGER NOT NULL,
"productQuantity" INTEGER NOT NULL,
"productName" TEXT NOT NULL,
"status" "STATUS" NOT NULL,
"customerName" TEXT NOT NULL,
"customerPhone" TEXT NOT NULL,
"customerAddress" TEXT NOT NULL,
"customerNote" TEXT NOT NULL,
"paymentType" "PAYMENT_TYPE" NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Order_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Order" ADD CONSTRAINT "Order_shopAccountId_fkey" FOREIGN KEY ("shopAccountId") REFERENCES "Profile"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "Order" DROP CONSTRAINT "Order_shopAccountId_fkey";
-- AddForeignKey
ALTER TABLE "Order" ADD CONSTRAINT "Order_shopAccountId_fkey" FOREIGN KEY ("shopAccountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+3 -1
View File
@@ -18,5 +18,7 @@ model Account {
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
profile Profile?
profile Profile? //one-to-one
orders Order[] //one-to-many
}
+29
View File
@@ -0,0 +1,29 @@
enum STATUS {
INITIATED
CONFIRMED
ONGOING
DELIVERED
CANCELLED
}
enum PAYMENT_TYPE {
COD
}
model Order {
id String @id @default(uuid())
shopAccountId String
account Account @relation(fields: [shopAccountId], references: [id], onDelete: Cascade)
productPrice Int
productQuantity Int
productName String
status STATUS
customerName String
customerPhone String
customerAddress String
customerNote String
paymentType PAYMENT_TYPE
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
+1
View File
@@ -9,4 +9,5 @@ model Profile {
shopAddress String?
shopMapLocation String?
shopCategory String?
}