Add family code system allowing multiple parents to access the same child's practice data. This is the foundation for the Suzuki Triangle model where both parents can supervise daily practice. Key features: - Family codes (FAM-XXXXXX) per student for sharing access - FamilyCodeDisplay modal for viewing/copying/regenerating codes - LinkChildForm modal for linking to existing child via code - parent_child junction table for many-to-many relationships - React Query mutations with proper cache invalidation API routes: - GET/POST /api/family/children/[playerId]/code - manage family codes - POST /api/family/link - link to child via family code - GET /api/family/children - list linked children Also includes classroom system foundation (Phase 1): - Classroom, enrollment, and presence schemas - Teacher classroom management APIs - Student enrollment request workflow - Real-time presence tracking infrastructure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
26 lines
1.1 KiB
SQL
26 lines
1.1 KiB
SQL
-- Custom SQL migration file, put your code below! --
|
|
-- Add missing indexes and generate family codes
|
|
|
|
-- ============================================================================
|
|
-- 1. Add missing indexes to parent_child table
|
|
-- ============================================================================
|
|
|
|
CREATE INDEX `idx_parent_child_parent` ON `parent_child` (`parent_user_id`);
|
|
--> statement-breakpoint
|
|
|
|
CREATE INDEX `idx_parent_child_child` ON `parent_child` (`child_player_id`);
|
|
--> statement-breakpoint
|
|
|
|
-- ============================================================================
|
|
-- 2. Generate family codes for existing players
|
|
-- ============================================================================
|
|
|
|
-- SQLite doesn't have built-in random string generation, so we use a combination
|
|
-- of hex(randomblob()) to create unique codes, then format them.
|
|
-- Format: FAM-XXXXXX where X is alphanumeric
|
|
-- The uniqueness constraint on family_code will ensure no collisions.
|
|
|
|
UPDATE `players`
|
|
SET `family_code` = 'FAM-' || UPPER(SUBSTR(HEX(RANDOMBLOB(3)), 1, 6))
|
|
WHERE `family_code` IS NULL;
|