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 | 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 39x 39x 39x 2x 2x 2x 2x | import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
import { classrooms } from './classrooms'
import { players } from './players'
import { users } from './users'
/**
* Classroom presence - ephemeral "in classroom" state
*
* Tracks which students are currently "in" a classroom for live sessions.
* A student can only be present in one classroom at a time (enforced by primary key on playerId).
*
* Presence is different from enrollment:
* - Enrollment: persistent registration in a classroom
* - Presence: currently active in the classroom for a live session
*
* When present, the teacher can:
* - Start practice sessions for the student
* - Observe the student's practice in real-time
* - Control the student's tutorial/abacus
*/
export const classroomPresence = sqliteTable(
'classroom_presence',
{
/** Player ID - also the primary key (one classroom at a time) */
playerId: text('player_id')
.primaryKey()
.references(() => players.id, { onDelete: 'cascade' }),
/** Classroom the student is currently in */
classroomId: text('classroom_id')
.notNull()
.references(() => classrooms.id, { onDelete: 'cascade' }),
/** When the student entered the classroom */
enteredAt: integer('entered_at', { mode: 'timestamp' })
.notNull()
.$defaultFn(() => new Date()),
/** Who put the student in the classroom (parent, teacher, or self) */
enteredBy: text('entered_by')
.notNull()
.references(() => users.id),
},
(table) => ({
/** Index for finding all students present in a classroom */
classroomIdx: index('idx_presence_classroom').on(table.classroomId),
})
)
export type ClassroomPresence = typeof classroomPresence.$inferSelect
export type NewClassroomPresence = typeof classroomPresence.$inferInsert
|