Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ AllCops:
Exclude:
- test/dummy/db/schema.rb
- test/dummy/db/queue_schema.rb
- test/dummy/db/persistent_schema.rb
- test/dummy/db/migrate/**/*
6 changes: 6 additions & 0 deletions app/models/upright/persistent_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Durable, replicated source-of-truth data (rollups, later incidents/maintenance) on the persistent DB.
class Upright::PersistentRecord < ActiveRecord::Base
self.abstract_class = true

connects_to database: { writing: :persistent, reading: :persistent }
end
Comment thread
lewispb marked this conversation as resolved.
2 changes: 1 addition & 1 deletion app/models/upright/rollups/probe_rollup.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Upright::Rollups::ProbeRollup < Upright::ApplicationRecord
class Upright::Rollups::ProbeRollup < Upright::PersistentRecord
self.table_name = "upright_rollups_probe_rollups"

enum :status, Upright::Status::VALUES, default: :operational
Expand Down
44 changes: 21 additions & 23 deletions test/dummy/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem "sqlite3"
#
# SQLite, for the engine's dummy test app. Three databases mirror production's
# logical split:
# primary - per-site probe results + Active Storage artifacts (the default
# connection; engine's create_upright_probe_results lives in
# ../../db/migrate, Active Storage in db/migrate)
# persistent - durable source-of-truth rollups (../../db/persistent_migrate)
# queue - Solid Queue (db/queue_migrate)
default: &default
adapter: sqlite3
max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
Expand All @@ -13,33 +14,30 @@ development:
primary:
<<: *default
database: storage/development.sqlite3
migrations_paths:
- db/migrate
- ../../db/migrate
persistent:
<<: *default
database: storage/development_persistent.sqlite3
migrations_paths: ../../db/persistent_migrate
queue:
<<: *default
database: storage/development_queue.sqlite3
migrations_paths: db/queue_migrate

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
primary:
<<: *default
database: storage/test.sqlite3
queue:
<<: *default
database: storage/test_queue.sqlite3
migrations_paths: db/queue_migrate


# SQLite3 write its data on the local filesystem, as such it requires
# persistent disks. If you are deploying to a managed service, you should
# make sure it provides disk persistence, as many don't.
#
# Similarly, if you deploy your application as a Docker container, you must
# ensure the database is located in a persisted volume.
production:
primary:
migrations_paths:
- db/migrate
- ../../db/migrate
persistent:
<<: *default
database: storage/test_persistent.sqlite3
migrations_paths: ../../db/persistent_migrate
queue:
<<: *default
database: storage/test_queue.sqlite3
migrations_paths: db/queue_migrate
25 changes: 25 additions & 0 deletions test/dummy/db/persistent_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.1].define(version: 2026_05_12_000001) do
create_table "upright_rollups_probe_rollups", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "period_start", null: false
t.string "probe_name", null: false
t.string "probe_service"
t.integer "status", default: 0, null: false
t.datetime "updated_at", null: false
t.float "uptime_fraction", null: false
t.index ["probe_name", "period_start"], name: "idx_on_probe_name_period_start_3a6029f64e", unique: true
t.index ["probe_service", "period_start"], name: "idx_on_probe_service_period_start_c65e2bccc5"
end
end
14 changes: 1 addition & 13 deletions test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.1].define(version: 2026_05_12_000001) do
ActiveRecord::Schema[8.1].define(version: 2025_01_14_000001) do
create_table "active_storage_attachments", force: :cascade do |t|
t.bigint "blob_id", null: false
t.datetime "created_at", null: false
Expand Down Expand Up @@ -54,18 +54,6 @@
t.index ["status"], name: "index_upright_probe_results_on_status"
end

create_table "upright_rollups_probe_rollups", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "period_start", null: false
t.string "probe_name", null: false
t.string "probe_service"
t.integer "status", default: 0, null: false
t.datetime "updated_at", null: false
t.float "uptime_fraction", null: false
t.index ["probe_name", "period_start"], name: "idx_on_probe_name_period_start_3a6029f64e", unique: true
t.index ["probe_service", "period_start"], name: "idx_on_probe_service_period_start_c65e2bccc5"
end

add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
end
2 changes: 0 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
ENV["RAILS_ENV"] = "test"

require_relative "../test/dummy/config/environment"
ActiveRecord::Migrator.migrations_paths = [ File.expand_path("../test/dummy/db/migrate", __dir__) ]
ActiveRecord::Migrator.migrations_paths << File.expand_path("../db/migrate", __dir__)
require "rails/test_help"
require "mocha/minitest"
require "webmock/minitest"
Expand Down