Skip to content

Split rollups into a replicated persistent database#87

Open
lewispb wants to merge 1 commit into
mainfrom
lewis/mysql-migration
Open

Split rollups into a replicated persistent database#87
lewispb wants to merge 1 commit into
mainfrom
lewis/mysql-migration

Conversation

@lewispb
Copy link
Copy Markdown
Member

@lewispb lewispb commented Jun 4, 2026

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

  • New Upright::PersistentRecord base (connects_to :persistent); Upright::Rollups::ProbeRollup moves onto it.
  • Rollups migration relocated to db/persistent_migrate.
  • Dummy app: three databases (primary / persistent / queue) with split schema files.

What doesn't change

  • The per-site primary connection (probe results + Active Storage) and queue are untouched. Existing single-database installs upgrade by adding an empty persistent database — no rename, no data migration (probe rollups is unreleased, so there's nothing to backfill).
  • The engine stays adapter-agnostic; its test suite still runs on SQLite (174 runs, 0 failures). Production (37signals' 37upright) maps persistent to a replicated MySQL instance and primary/queue to a local one — see the companion 37upright PR.

🤖 Generated with Claude Code

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.
Copilot AI review requested due to automatic review settings June 4, 2026 10:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::PersistentRecord and move Upright::Rollups::ProbeRollup onto the persistent connection.
  • Relocate the rollups migration into db/persistent_migrate and split the dummy app schema into schema.rb (primary) + persistent_schema.rb.
  • Update the dummy app database.yml to define primary/persistent/queue databases and set migrations_paths per 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
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.

2 participants