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

export const notifications = mysqlTable('msg_notifications', {
  id: char('id', { length: 36 }).notNull().primaryKey(),
  userId: char('user_id', { length: 36 }).notNull(),
  type: varchar('type', { length: 50 }).notNull(),
  title: varchar('title', { length: 200 }).notNull(),
  content: text('content').notNull(),
  channel: varchar('channel', { length: 20 }).notNull().default('in_app'),
  isRead: boolean('is_read').notNull().default(false),
  metadata: json('metadata'),
  createdAt: timestamp('created_at').notNull().defaultNow(),
});

export const notificationPreferences = mysqlTable('msg_notification_preferences', {
  userId: char('user_id', { length: 36 }).notNull().primaryKey(),
  emailEnabled: boolean('email_enabled').notNull().default(true),
  smsEnabled: boolean('sms_enabled').notNull().default(false),
  pushEnabled: boolean('push_enabled').notNull().default(true),
  inAppEnabled: boolean('in_app_enabled').notNull().default(true),
});

export type Notification = typeof notifications.$inferSelect;
export type NotificationPreference = typeof notificationPreferences.$inferSelect;
