Add blog authors support
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "BlogAuthor" (
|
||||
"id" TEXT NOT NULL,
|
||||
"blogPostId" TEXT NOT NULL,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"type" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"website" TEXT,
|
||||
"imageUrl" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "BlogAuthor_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BlogAuthor_blogPostId_sortOrder_idx" ON "BlogAuthor"("blogPostId", "sortOrder");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BlogAuthor" ADD CONSTRAINT "BlogAuthor_blogPostId_fkey" FOREIGN KEY ("blogPostId") REFERENCES "BlogPost"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -77,4 +77,20 @@ model BlogPost {
|
||||
publishedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
authors BlogAuthor[]
|
||||
}
|
||||
|
||||
model BlogAuthor {
|
||||
id String @id @default(cuid())
|
||||
blogPostId String
|
||||
blogPost BlogPost @relation(fields: [blogPostId], references: [id], onDelete: Cascade)
|
||||
sortOrder Int @default(0)
|
||||
type String
|
||||
name String
|
||||
website String?
|
||||
imageUrl String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([blogPostId, sortOrder])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user