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

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

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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 752x 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 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, real, sqliteTable, text } from 'drizzle-orm/sqlite-core'
import { users } from './users'
 
/**
 * Abacus display settings table - UI preferences per user
 *
 * One-to-one with users table. Stores abacus display configuration.
 * Deleted when user is deleted (cascade).
 */
export const abacusSettings = sqliteTable('abacus_settings', {
  /** Primary key and foreign key to users table */
  userId: text('user_id')
    .primaryKey()
    .references(() => users.id, { onDelete: 'cascade' }),
 
  /** Color scheme for beads */
  colorScheme: text('color_scheme', {
    enum: ['monochrome', 'place-value', 'heaven-earth', 'alternating'],
  })
    .notNull()
    .default('place-value'),
 
  /** Bead shape */
  beadShape: text('bead_shape', {
    enum: ['diamond', 'circle', 'square'],
  })
    .notNull()
    .default('diamond'),
 
  /** Color palette */
  colorPalette: text('color_palette', {
    enum: ['default', 'colorblind', 'mnemonic', 'grayscale', 'nature'],
  })
    .notNull()
    .default('default'),
 
  /** Hide inactive beads */
  hideInactiveBeads: integer('hide_inactive_beads', { mode: 'boolean' }).notNull().default(false),
 
  /** Color numerals based on place value */
  coloredNumerals: integer('colored_numerals', { mode: 'boolean' }).notNull().default(false),
 
  /** Scale factor for abacus size */
  scaleFactor: real('scale_factor').notNull().default(1.0),
 
  /** Show numbers below abacus */
  showNumbers: integer('show_numbers', { mode: 'boolean' }).notNull().default(true),
 
  /** Enable animations */
  animated: integer('animated', { mode: 'boolean' }).notNull().default(true),
 
  /** Enable interaction */
  interactive: integer('interactive', { mode: 'boolean' }).notNull().default(false),
 
  /** Enable gesture controls */
  gestures: integer('gestures', { mode: 'boolean' }).notNull().default(false),
 
  /** Enable sound effects */
  soundEnabled: integer('sound_enabled', { mode: 'boolean' }).notNull().default(true),
 
  /** Sound volume (0.0 - 1.0) */
  soundVolume: real('sound_volume').notNull().default(0.8),
 
  /** Display numbers as abaci throughout the app where practical */
  nativeAbacusNumbers: integer('native_abacus_numbers', { mode: 'boolean' })
    .notNull()
    .default(false),
 
  /** Number of columns on the user's physical abacus (for vision detection) */
  physicalAbacusColumns: integer('physical_abacus_columns').notNull().default(4),
})
 
export type AbacusSettings = typeof abacusSettings.$inferSelect
export type NewAbacusSettings = typeof abacusSettings.$inferInsert