// src/server/features/notifications/db/pending_notifications.table.ts
// Pending notifications table for persistence of critical notifications

import { mysqlTable, varchar, timestamp, text, json } from 'drizzle-orm/mysql-core';

export const pendingNotifications = mysqlTable('pending_notifications', {
  id: varchar('id', { length: 36 }).primaryKey(),
  userId: varchar('user_id', { length: 36 }).notNull(), // Target user ID
  roomId: varchar('room_id', { length: 50 }).notNull(), // Target room (room:admins, room:managers, room:user_{id})
  event: varchar('event', { length: 50 }).notNull(), // Event name (approval:created, approval:resolved, etc.)
  data: json('data').notNull(), // Event data (JSON)
  readAt: timestamp('read_at'), // When notification was read
  createdAt: timestamp('created_at').notNull().defaultNow(),
  archivedAt: timestamp('archived_at'), // Soft delete
});

export type PendingNotification = typeof pendingNotifications.$inferSelect;
export type NewPendingNotification = typeof pendingNotifications.$inferInsert;
