Split rollups into a replicated persistent database#87
Open
lewispb wants to merge 1 commit into
Open
Conversation
Add Upright::PersistentRecord (connects_to :persistent) for the durable, replicated source-of-truth tables and move ProbeRollup onto it. The per-site `primary` connection (probe results + Active Storage) and `queue` are unchanged, so existing single-db installs upgrade by just adding an empty persistent database. - ProbeRollup < Upright::PersistentRecord - rollups migration moves to db/persistent_migrate - dummy app: primary/persistent/queue config + split schema files Production maps these to separate MySQL instances; the engine stays adapter-agnostic and runs its tests on SQLite.
There was a problem hiding this comment.
Pull request overview
This PR introduces a third logical database (persistent) intended to hold durable, replicated “source of truth” data (starting with rollups), separating it from per-site probe data (primary) and job data (queue).
Changes:
- Add
Upright::PersistentRecordand moveUpright::Rollups::ProbeRolluponto thepersistentconnection. - Relocate the rollups migration into
db/persistent_migrateand split the dummy app schema intoschema.rb(primary) +persistent_schema.rb. - Update the dummy app
database.ymlto defineprimary/persistent/queuedatabases and setmigrations_pathsper DB.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/test_helper.rb | Removes manual ActiveRecord::Migrator.migrations_paths overrides (now driven via per-DB migrations_paths). |
| test/dummy/db/schema.rb | Drops rollups table from the primary schema and updates schema version to the latest primary migration. |
| test/dummy/db/persistent_schema.rb | Adds a dedicated schema dump for the new persistent database (rollups table). |
| test/dummy/config/database.yml | Defines three DBs and per-DB migration paths to mirror the intended production split. |
| db/persistent_migrate/20260512000001_create_upright_rollups.rb | Introduces the rollups table migration under a dedicated persistent migration directory. |
| app/models/upright/rollups/probe_rollup.rb | Switches the rollup model base class to Upright::PersistentRecord. |
| app/models/upright/persistent_record.rb | Introduces a base AR class connected to the persistent database. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
45
to
56
| production: | ||
| primary: | ||
| <<: *default | ||
| migrations_paths: | ||
| - db/migrate | ||
| - ../../db/migrate | ||
| persistent: | ||
| <<: *default | ||
| migrations_paths: ../../db/persistent_migrate | ||
| queue: | ||
| <<: *default | ||
| migrations_paths: db/queue_migrate |
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.
Introduces a third logical database so the public-status-page data can become a durable, replicated source of truth, separate from each site's disposable probe data.
What changes
Upright::PersistentRecordbase (connects_to :persistent);Upright::Rollups::ProbeRollupmoves onto it.db/persistent_migrate.primary/persistent/queue) with split schema files.What doesn't change
primaryconnection (probe results + Active Storage) andqueueare untouched. Existing single-database installs upgrade by adding an emptypersistentdatabase — no rename, no data migration (probe rollups is unreleased, so there's nothing to backfill).persistentto a replicated MySQL instance andprimary/queueto a local one — see the companion 37upright PR.🤖 Generated with Claude Code