Add blog categories and default SUPER_ADMIN store scope to Mana Collection.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
3da8a5d4a2
commit
20e81ade19
@@ -0,0 +1,35 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "BlogCategory" (
|
||||
"id" TEXT NOT NULL,
|
||||
"storeId" TEXT NOT NULL,
|
||||
"parentId" TEXT,
|
||||
"nameFa" TEXT NOT NULL,
|
||||
"nameEn" TEXT NOT NULL DEFAULT '',
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
|
||||
CONSTRAINT "BlogCategory_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "BlogPost" ADD COLUMN "categoryId" TEXT;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BlogCategory_storeId_idx" ON "BlogCategory"("storeId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BlogCategory_parentId_idx" ON "BlogCategory"("parentId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BlogCategory_sortOrder_idx" ON "BlogCategory"("sortOrder");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BlogPost_categoryId_idx" ON "BlogPost"("categoryId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BlogCategory" ADD CONSTRAINT "BlogCategory_storeId_fkey" FOREIGN KEY ("storeId") REFERENCES "Store"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BlogCategory" ADD CONSTRAINT "BlogCategory_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "BlogCategory"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BlogPost" ADD CONSTRAINT "BlogPost_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "BlogCategory"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
+29
-8
@@ -126,6 +126,7 @@ model Store {
|
||||
|
||||
products Product[]
|
||||
categories Category[]
|
||||
blogCategories BlogCategory[]
|
||||
brands Brand[]
|
||||
blogs BlogPost[]
|
||||
orderItems OrderItem[]
|
||||
@@ -219,24 +220,44 @@ model ProductVariant {
|
||||
@@index([productId])
|
||||
}
|
||||
|
||||
model BlogCategory {
|
||||
id String @id @default(cuid())
|
||||
storeId String
|
||||
store Store @relation(fields: [storeId], references: [id], onDelete: Cascade)
|
||||
parentId String?
|
||||
parent BlogCategory? @relation("BlogCategoryTree", fields: [parentId], references: [id], onDelete: SetNull)
|
||||
children BlogCategory[] @relation("BlogCategoryTree")
|
||||
nameFa String
|
||||
nameEn String @default("")
|
||||
sortOrder Int @default(0)
|
||||
blogs BlogPost[]
|
||||
|
||||
@@index([storeId])
|
||||
@@index([parentId])
|
||||
@@index([sortOrder])
|
||||
}
|
||||
|
||||
model BlogPost {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
storeId String
|
||||
store Store @relation(fields: [storeId], references: [id], onDelete: Cascade)
|
||||
store Store @relation(fields: [storeId], references: [id], onDelete: Cascade)
|
||||
categoryId String?
|
||||
category BlogCategory? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
|
||||
title String
|
||||
summary String @default("")
|
||||
body String @default("")
|
||||
author String @default("")
|
||||
summary String @default("")
|
||||
body String @default("")
|
||||
author String @default("")
|
||||
imageUrl String?
|
||||
imageKey String?
|
||||
published Boolean @default(true)
|
||||
published Boolean @default(true)
|
||||
metaTitle String?
|
||||
metaDescription String?
|
||||
slug String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([storeId])
|
||||
@@index([categoryId])
|
||||
@@index([published])
|
||||
@@index([slug])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user