All files / web/src/db/schema room-reports.ts

100% Statements 47/47
100% Branches 1/1
100% Functions 1/1
100% Lines 47/47

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 482x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x  
import { createId } from '@paralleldrive/cuid2'
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
import { arcadeRooms } from './arcade-rooms'
 
/**
 * Reports submitted by room members about other members
 */
export const roomReports = sqliteTable('room_reports', {
  id: text('id')
    .primaryKey()
    .$defaultFn(() => createId()),
 
  roomId: text('room_id')
    .notNull()
    .references(() => arcadeRooms.id, { onDelete: 'cascade' }),
 
  // Who reported
  reporterId: text('reporter_id').notNull(),
  reporterName: text('reporter_name', { length: 50 }).notNull(),
 
  // Who was reported
  reportedUserId: text('reported_user_id').notNull(),
  reportedUserName: text('reported_user_name', { length: 50 }).notNull(),
 
  // Report details
  reason: text('reason', {
    enum: ['harassment', 'cheating', 'inappropriate-name', 'spam', 'afk', 'other'],
  }).notNull(),
  details: text('details', { length: 500 }), // Optional additional context
 
  // Status tracking
  status: text('status', {
    enum: ['pending', 'reviewed', 'dismissed'],
  })
    .notNull()
    .default('pending'),
 
  // Timestamps
  createdAt: integer('created_at', { mode: 'timestamp' })
    .notNull()
    .$defaultFn(() => new Date()),
  reviewedAt: integer('reviewed_at', { mode: 'timestamp' }),
  reviewedBy: text('reviewed_by'), // Host user ID who reviewed
})
 
export type RoomReport = typeof roomReports.$inferSelect
export type NewRoomReport = typeof roomReports.$inferInsert