refactor: change feed channel notifyFrequency type to enum

This commit is contained in:
moonrailgun 2024-07-13 16:32:03 +08:00
parent b355a677d3
commit 2ce5597dfe
3 changed files with 26 additions and 6 deletions

View File

@ -0,0 +1,12 @@
/*
Warnings:
- The `notifyFrequency` column on the `FeedChannel` table would be dropped and recreated. This will lead to data loss if there is data in the column.
*/
-- CreateEnum
CREATE TYPE "FeedChannelNotifyFrequency" AS ENUM ('event', 'day', 'week', 'month');
-- AlterTable
ALTER TABLE "FeedChannel" DROP COLUMN "notifyFrequency",
ADD COLUMN "notifyFrequency" "FeedChannelNotifyFrequency" NOT NULL DEFAULT 'day';

View File

@ -446,13 +446,20 @@ model SurveyResult {
@@index([sessionId])
}
enum FeedChannelNotifyFrequency {
event
day
week
month
}
model FeedChannel {
id String @id @default(cuid()) @db.VarChar(30)
workspaceId String @db.VarChar(30)
id String @id @default(cuid()) @db.VarChar(30)
workspaceId String @db.VarChar(30)
name String
notifyFrequency String @default("day")
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
notifyFrequency FeedChannelNotifyFrequency @default(day)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
workspace Workspace @relation(fields: [workspaceId], references: [id], onUpdate: Cascade, onDelete: Cascade)
events FeedEvent[]

View File

@ -1,12 +1,13 @@
import * as z from "zod"
import * as imports from "./schemas"
import { FeedChannelNotifyFrequency } from "@prisma/client"
import { CompleteWorkspace, RelatedWorkspaceModelSchema, CompleteFeedEvent, RelatedFeedEventModelSchema, CompleteNotification, RelatedNotificationModelSchema } from "./index"
export const FeedChannelModelSchema = z.object({
id: z.string(),
workspaceId: z.string(),
name: z.string(),
notifyFrequency: z.string(),
notifyFrequency: z.nativeEnum(FeedChannelNotifyFrequency),
createdAt: z.date(),
updatedAt: z.date(),
})