feat : ask for noti
This commit is contained in:
@@ -793,3 +793,24 @@ export const commentReadState = commentsSchema.table("read_state", {
|
||||
target: text("target").notNull(),
|
||||
seenAt: timestamp("seen_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
}, (table) => [primaryKey({ columns: [table.userId, table.target] })]);
|
||||
|
||||
export const notifications = pgTable("notification", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
eventKey: text("event_key").notNull(),
|
||||
kind: text("kind").notNull(),
|
||||
title: text("title").notNull(),
|
||||
body: text("body").notNull(),
|
||||
url: text("url").notNull(),
|
||||
adminOnly: boolean("admin_only").default(false).notNull(),
|
||||
commentId: uuid("comment_id").references(() => comments.id, { onDelete: "cascade" }),
|
||||
messageId: uuid("message_id").references(() => commissionMessages.id, { onDelete: "cascade" }),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
readAt: timestamp("read_at", { withTimezone: true }),
|
||||
}, (table) => [
|
||||
uniqueIndex("notification_user_event_unique").on(table.userId, table.eventKey),
|
||||
index("notification_user_time_idx").on(table.userId, table.createdAt, table.id),
|
||||
index("notification_user_unread_idx").on(table.userId).where(sql`${table.readAt} is null`),
|
||||
index("notification_comment_idx").on(table.commentId),
|
||||
index("notification_message_idx").on(table.messageId),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user