Add PostgreSQL dual writes and room metrics#171
Merged
Conversation
Mirror new application data and pseudonymous metrics into PostgreSQL while MongoDB remains the source of truth. Add versioned migrations, Compose services, retention controls, and focused coverage for the migration path.
Describe the migration by its schema responsibility rather than the temporary dual-write rollout strategy. Keep the initial username index compatible with the final schema when migrations are replayed.
Replace the custom migration registry with a canonical Prisma schema and Prisma Migrate history. Run migrate deploy as a one-shot production service and enforce schema validation and drift checks in CI.
Normalize solve penalties and add stable cursor ordering. Mirror only dirty room participants, attempts, and results to avoid replaying room history on every save.
Move shared event and protocol constants to JSON so the Vite client uses ESM while the CommonJS server reads the same data. Import the Material UI theme provider through its supported direct package entry to avoid the optimizer's broken barrel initialization.
This was referenced Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
appandanalyticsschemas in Prismaprisma migrate deployas a one-shot production Compose serviceWhy
This starts ingesting durable solve and analytics data into PostgreSQL while keeping the existing MongoDB-backed application behavior unchanged. Prisma provides the canonical PostgreSQL schema and migration history, while
pgremains the small runtime layer for PostgreSQL-specific dual-write upserts.Incremental writes prevent solve ingestion from becoming quadratic as room history grows. Normalized penalty fields keep solve statistics queryable without JSON extraction, and unchanged same-timestamp retries are true no-ops to reduce unnecessary PostgreSQL churn.
Rollout and privacy
POSTGRES_ENABLED=false; metrics can be disabled independently withMETRICS_ENABLED=false.DIRECT_DATABASE_URLcan provide a direct migration connection when runtimeDATABASE_URLtraffic is pooled.Validation
yarn lintyarn test— 45 tests passedyarn buildprisma validatecookieadvisory remains