Skip to content

Split rollups into a replicated persistent database#87

Merged
lewispb merged 5 commits into
mainfrom
lewis/mysql-migration
Jun 11, 2026
Merged

Split rollups into a replicated persistent database#87
lewispb merged 5 commits into
mainfrom
lewis/mysql-migration

Conversation

@lewispb

@lewispb lewispb commented Jun 4, 2026

Copy link
Copy Markdown
Member

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

  • 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.

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

Copilot AI left a comment

Copy link
Copy Markdown

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 thread test/dummy/config/database.yml Outdated
lewispb and others added 2 commits June 11, 2026 09:59
* 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>
Copilot AI review requested due to automatic review settings June 11, 2026 09:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Comment thread app/models/upright/persistent_record.rb
lewispb and others added 2 commits June 11, 2026 11:10
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>
Copilot AI review requested due to automatic review settings June 11, 2026 10:14
@lewispb lewispb merged commit 716802a into main Jun 11, 2026
9 checks passed
@lewispb lewispb review requested due to automatic review settings June 11, 2026 10:35
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