30 lines
843 B
TypeScript
30 lines
843 B
TypeScript
import {
|
|
boolean,
|
|
jsonb,
|
|
pgTable,
|
|
text,
|
|
uniqueIndex,
|
|
uuid,
|
|
} from "drizzle-orm/pg-core";
|
|
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
|
import type z from "zod";
|
|
|
|
export const notifications = pgTable(
|
|
"notifications",
|
|
{
|
|
id: uuid("id").defaultRandom().primaryKey(),
|
|
name: text("name").notNull(),
|
|
description: text("description").notNull(),
|
|
active: boolean("active").default(false),
|
|
interval: text("interval").default("5"),
|
|
options: jsonb("options").default([]),
|
|
},
|
|
(table) => [uniqueIndex("notify_name").on(table.name)],
|
|
);
|
|
|
|
export const notificationSchema = createSelectSchema(notifications);
|
|
export const newNotificationSchema = createInsertSchema(notifications);
|
|
|
|
export type Notification = z.infer<typeof notificationSchema>;
|
|
export type NewNotification = z.infer<typeof newNotificationSchema>;
|