Files
lstV2/database/schema/notifications.ts

37 lines
1.2 KiB
TypeScript

import {
boolean,
jsonb,
pgTable,
text,
timestamp,
uniqueIndex,
uuid,
} from "drizzle-orm/pg-core";
import { createSelectSchema } from "drizzle-zod";
export const notifications = pgTable(
"notifications",
{
notify_id: uuid("notify_id").defaultRandom().primaryKey(),
name: text("name").notNull(),
description: text("description").notNull(),
checkInterval: text("checkInterval").default("1"),
timeType: text("timeType").default("hour"),
emails: text("emails"),
active: boolean("active").default(false),
lastRan: timestamp("lastRan").defaultNow(),
notifiySettings: jsonb("notifiySettings").default({}),
},
(table) => [
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
uniqueIndex("notify_name").on(table.name),
]
);
// Schema for inserting a user - can be used to validate API requests
// export const insertRolesSchema = createInsertSchema(roles, {
// name: z.string().min(3, {message: "Role name must be more than 3 letters"}),
// });
// Schema for selecting a Expenses - can be used to validate API responses
export const selectNotificationsSchema = createSelectSchema(notifications);