Skip to content

Add sync scripts and readiness API with UI warnings#10

Merged
pstaylor-patrick merged 1 commit into
mainfrom
baguette-mvp
Feb 10, 2026
Merged

Add sync scripts and readiness API with UI warnings#10
pstaylor-patrick merged 1 commit into
mainfrom
baguette-mvp

Conversation

@pstaylor-patrick

@pstaylor-patrick pstaylor-patrick commented Feb 10, 2026

Copy link
Copy Markdown
Collaborator

Related to #7

👋 TL;DR

Added database sync scripts to populate local, Neon, and Supabase databases from GCP source, plus a readiness API and UI indicators to show when platforms are empty or out of sync.

🔎 Details

This PR introduces a complete sync system for database targets and visual readiness indicators:

  1. New sync scripts (scripts/db-sync.ts):

    • npm run db:sync:local, :neon, :supabase, :all to reset and repopulate targets from GCP dumps
    • Requires DB_SYNC_ALLOW_DESTRUCTIVE=true or interactive confirmation for safety
    • Verifies sync success with table and row counts
  2. Readiness API (GET /api/readiness):

    • Returns table count and sample row count for each configured platform
    • Sets ready: true when both counts are > 0
    • Gracefully handles unreachable platforms
  3. UI integration:

    • Platform pills show amber warning dots when not ready
    • Warning cards appear for selected empty platforms with sync instructions
    • DataDiff and PerformanceChart show diagnostic hints when row counts differ or are zero
  4. Documentation:

    • Added .context/sync-and-readiness.md with full sync workflow and API docs
    • Updated CLAUDE.md with new npm scripts
  5. Testing & robustness:

    • Added comprehensive unit tests for schema compare API
    • Improved error handling in schema compare route
    • Added safety checks to prevent syncing to GCP (read-only source)

✅ How to Test

  1. Sync a target database:

    • Run npm run db:pull:dump to export from GCP first
    • Run npm run db:sync:local (confirm destruction when prompted)
    • Verify output shows table counts and row counts
  2. Check readiness API:

    • Visit http://localhost:3002/api/readiness
    • Should return JSON array with platform statuses
    • Empty platforms should show ready: false
  3. UI indicators:

    • Select an empty platform in the dashboard
    • Should see warning card with sync instructions
    • Platform pill should have amber warning dot
  4. Data comparison:

    • Compare data between a ready and not-ready platform
    • Should see diagnostic hint about 0 rows
    • Performance chart should show warning about misleading latency
  5. Schema compare error handling:

    • Test schema compare with a misconfigured platform
    • Should return 500 with error message instead of crashing

🥜 GIF

lack-of-hustle

@pstaylor-patrick pstaylor-patrick marked this pull request as ready for review February 10, 2026 04:26
@pstaylor-patrick pstaylor-patrick merged commit b0eaba3 into main Feb 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant