feat : ask for noti
CI / Verify (push) Successful in 1m50s
CI / Build immutable images and deploy (push) Successful in 2m59s

This commit is contained in:
2026-10-08 02:23:59 +07:00 Unverified
parent 5812d99715
commit 9bc710c94b
34 changed files with 10913 additions and 201 deletions
+21
View File
@@ -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),
]);