-
Notifications
You must be signed in to change notification settings - Fork 4
feat(db): Database consolidation - Unified board tables #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Create 22 unified board_* tables with board_type discriminator column and migrate all data from kilter_* and tension_* tables: - Phase 1: board_attempts, board_difficulty_grades (+ MoonBoard seed data) - Phase 2: board_products, board_sets, board_product_sizes, board_layouts, board_holes, board_placement_roles, board_leds, board_placements, board_product_sizes_layouts_sets - Phase 3: board_climbs, board_climb_stats, board_climb_holds, board_climb_stats_history, board_beta_links - Phase 4: board_users, board_circuits, board_circuits_climbs, board_walls, board_tags - Phase 5: board_user_syncs, board_shared_syncs Data migration verified: - 435,997 climbs migrated (318K kilter + 118K tension) - 5.5M climb_holds migrated with deduplication - All foreign key constraints validated 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add UNIFIED_TABLES constant and helper functions to table-select.ts - Update shared-sync.ts to use unified tables for: - board_attempts, board_difficulty_grades (seeded with MoonBoard data) - board_climbs, board_climb_stats, board_climb_stats_history - board_climb_holds, board_beta_links - board_shared_syncs - Update user-sync.ts to use unified tables for: - board_users, board_walls, board_circuits, board_tags - board_user_syncs - draft_climbs (uses board_climbs) - Keep legacy getTable for ascents/bids (phased out, already in boardsesh_ticks) - All inserts now include boardType, conflict targets include boardType - All queries filter by boardType 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add Implementation Status Summary table showing: - Phase 0-5: All complete (migrations applied) - Task 4-5: Complete (table-select.ts and sync functions) - Task 6: Pending (query files with raw SQL) - Task 7 & Phase 6: Planned 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update create-climb-filters.ts: - Use board_climb_holds with board_type filter for hold state conditions - Use board_product_sizes with board_type filter for tall climbs query - Keep legacy getTableName for ascents/bids (phased out) - Update holds-heatmap.ts: - Use board_climb_holds with board_type filter in user stats queries - Keep legacy getTableName for ascents/bids (phased out) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ed tables - Update setter-stats.ts to use UNIFIED_TABLES with board_type filter - Update queries.ts to use unified table names (board_climbs, board_climb_stats, etc.) - Eliminate product_sizes JOIN by using getSizeEdges() for edge values - Mark Task 6 as complete in documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Claude ReviewIssues Found
|
- Update create-climb-filters.ts to use UNIFIED_TABLES directly - Remove `tables` parameter, now uses unified tables internally - Add board_type filter to baseConditions for all climb queries - Add getClimbHoldsJoinConditions() helper with board_type filter - Update holds-heatmap.ts to use UNIFIED_TABLES - Fix potential stale data issue where sync writes only to unified tables This ensures heatmap and filter queries read from the same tables that sync writes to, preventing data inconsistency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Claude Review
Issues
Minor Notes
|
## Changes ### Ascent/Bid Data Migration - All ascent/bid reads now use boardsesh_ticks table - All ascent/bid writes now use boardsesh_ticks table - Switched from Aurora user_id (integer) to NextAuth userId (string) - Removed dual-write pattern from user-sync.ts ### Files Updated - saveAscent.ts: Write to boardsesh_ticks with NextAuth userId - saveAscent/route.ts: Require NextAuth session, pass user.id - get-logbook.ts: Read from boardsesh_ticks - create-climb-filters.ts: Personal progress uses boardsesh_ticks - holds-heatmap.ts: User data queries use boardsesh_ticks - heatmap/route.ts: Use getServerSession for NextAuth - user-sync.ts: Remove legacy table writes - aurora-credentials/route.ts: Remove migration call ### Files Deleted - migrate-user-history.ts: No longer needed - migrate-users-cron/route.ts: Cron job no longer needed ### Migration - 0030_drop_legacy_ascents_bids.sql: Drop kilter/tension ascents/bids tables ### Additional Fixes - saveClimb.ts: Use unified boardClimbs table - beta/route.ts: Use unified boardBetaLinks table - view/page.tsx: Use unified boardBetaLinks table - slug-utils.ts: Use unified tables 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Minor issues noted below, but nothing blocking. Issues Found
Documentation Check✅ Documentation updated in |
Summary
Complete database consolidation from 36 board-specific Aurora tables to 18 unified tables with
board_typediscriminator.Changes
Phase 1-5: Unified Tables (Previously Completed)
board_*tables with composite primary keystable-select.tswithUNIFIED_TABLESconstantPhase 6: Ascents/Bids Migration (This Update)
Key Decision: Switched from Aurora
user_id(integer) to NextAuthuserId(string) for all ascent/bid data. Data not associated with NextAuth users is dropped.Files Updated:
saveAscent.ts: Write toboardsesh_tickswith NextAuth userIdsaveAscent/route.ts: Require NextAuth sessionget-logbook.ts: Read fromboardsesh_tickscreate-climb-filters.ts: Personal progress filters useboardsesh_ticksholds-heatmap.ts: User data queries useboardsesh_ticksheatmap/route.ts: UsegetServerSessionfor NextAuthuser-sync.ts: Remove dual-write to legacy tablesaurora-credentials/route.ts: Remove legacy migration callsaveClimb.ts: Use unifiedboardClimbstablebeta/route.ts: Use unifiedboardBetaLinkstableview/page.tsx: Use unifiedboardBetaLinkstableslug-utils.ts: Use unified tablesFiles Deleted:
migrate-user-history.ts: No longer neededmigrate-users-cron/route.ts: Cron job no longer neededMigration Added:
0030_drop_legacy_ascents_bids.sql: Dropkilter_ascents,kilter_bids,tension_ascents,tension_bidsTesting
npm run buildpassesnpm run db:migrateruns successfullyboard_typefilteringRemaining Work
🤖 Generated with Claude Code