All files / web/src/db/schema worksheet-settings.ts

100% Statements 36/36
100% Branches 0/0
100% Functions 0/0
100% Lines 36/36

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 372x 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 { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
 
/**
 * Worksheet generator settings table - persists user preferences per worksheet type
 *
 * Uses JSON blob approach for flexibility across different worksheet types
 * (addition, subtraction, multiplication, etc.)
 *
 * The config column stores versioned JSON that is validated at runtime
 * See src/app/create/worksheets/config-schemas.ts for schema definitions
 *
 * Note: No foreign key constraint - allows guest users to save settings
 * (matches pattern used by room_members table)
 */
export const worksheetSettings = sqliteTable('worksheet_settings', {
  /** Unique identifier (UUID) */
  id: text('id').primaryKey(),
 
  /** User ID (may be authenticated user or guest ID) */
  userId: text('user_id').notNull(),
 
  /** Type of worksheet: 'addition', 'subtraction', 'multiplication', etc. */
  worksheetType: text('worksheet_type').notNull(),
 
  /** JSON blob containing versioned settings (see config-schemas.ts for types) */
  config: text('config').notNull(),
 
  /** Timestamp of creation */
  createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
 
  /** Timestamp of last update */
  updatedAt: integer('updated_at', { mode: 'timestamp' }).notNull(),
})
 
export type WorksheetSettings = typeof worksheetSettings.$inferSelect
export type NewWorksheetSettings = typeof worksheetSettings.$inferInsert