Split rollups into a replicated persistent database#87
Merged
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.
* origin/main: Show an environment badge in the header outside production Use HTTPS + secure cookies in all deployed environments, not just production
The new persistent DB's schema dump triggers Layout/SpaceInsideArrayLiteralBrackets on its Rails-generated t.index arrays, just like schema.rb and queue_schema.rb — add it to the same AllCops/Exclude list. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The production env in the dummy database.yml omitted database: for primary/persistent/queue, so db:prepare under RAILS_ENV=production would raise. Mirror the development/test sections with explicit sqlite paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The engine's dummy app only ever runs under test (and development); nothing deploys it or runs it with RAILS_ENV=production. The production block was dead config, so remove it rather than maintain database paths for a section that never executes. Reverts the padding from the prior commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
This supports using MySQL for replication.
What changes
Upright::PersistentRecordbase (connects_to :persistent);Upright::Rollups::ProbeRollupmoves onto it.db/persistent_migrate.primary/persistent/queue) with split schema files.