Add scheduled automatic content drafts with Codex and image automation
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "PageContentAutomation" (
|
||||
"id" TEXT NOT NULL,
|
||||
"pageId" TEXT NOT NULL,
|
||||
"requestedById" TEXT NOT NULL,
|
||||
"enabled" BOOLEAN NOT NULL DEFAULT false,
|
||||
"weekdays" INTEGER[] DEFAULT ARRAY[1, 2, 3, 4, 5]::INTEGER[],
|
||||
"times" TEXT[] DEFAULT ARRAY['09:00']::TEXT[],
|
||||
"brief" TEXT NOT NULL DEFAULT '',
|
||||
"targets" "Platform"[] DEFAULT ARRAY['FACEBOOK']::"Platform"[],
|
||||
"nextRunAt" TIMESTAMP(3),
|
||||
"lastQueuedAt" TIMESTAMP(3),
|
||||
"lastError" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "PageContentAutomation_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "PageContentAutomation_pageId_key" ON "PageContentAutomation"("pageId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "PageContentAutomation_enabled_nextRunAt_idx" ON "PageContentAutomation"("enabled", "nextRunAt");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PageContentAutomation" ADD CONSTRAINT "PageContentAutomation_pageId_fkey" FOREIGN KEY ("pageId") REFERENCES "Page"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PageContentAutomation" ADD CONSTRAINT "PageContentAutomation_requestedById_fkey" FOREIGN KEY ("requestedById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -91,6 +91,7 @@ model User {
|
||||
teamInvitesSent TeamInvite[] @relation("TeamInviteSender")
|
||||
approvalAssignments ApprovalRequest[] @relation("ApprovalAssignee")
|
||||
approvalRequestsSent ApprovalRequest[] @relation("ApprovalRequester")
|
||||
contentAutomations PageContentAutomation[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -168,6 +169,7 @@ model Page {
|
||||
aiUsage AiUsage[]
|
||||
generationJobs PostGenerationJob[]
|
||||
teamPage TeamPage?
|
||||
contentAutomation PageContentAutomation?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -489,6 +491,27 @@ enum PostGenerationStatus {
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
// Recurring draft creation. The existing queue owns content and image generation.
|
||||
model PageContentAutomation {
|
||||
id String @id @default(cuid())
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
requestedById String
|
||||
requestedBy User @relation(fields: [requestedById], references: [id], onDelete: Restrict)
|
||||
enabled Boolean @default(false)
|
||||
weekdays Int[] @default([1, 2, 3, 4, 5])
|
||||
times String[] @default(["09:00"])
|
||||
brief String @default("")
|
||||
targets Platform[] @default([FACEBOOK])
|
||||
nextRunAt DateTime?
|
||||
lastQueuedAt DateTime?
|
||||
lastError String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([enabled, nextRunAt])
|
||||
}
|
||||
|
||||
// Durable creation queue. The output is always a draft and never a published post.
|
||||
model PostGenerationJob {
|
||||
id String @id @default(cuid())
|
||||
|
||||
Reference in New Issue
Block a user