Back to Source Monitor

Data Migration and Source Model Updates

.vbw-planning/milestones/ui-fixes-and-smart-scraping/phases/05-simplify-source-status/01-PLAN.md

0.13.01.4 KB
Original Source

Plan 01: Data Migration and Source Model Updates

Goal

Create the database migration to rename the 7 health statuses down to 4, and update the Source model's default attribute value.

Tasks

Task 1: Create data migration for health_status column values

Files: db/migrate/YYYYMMDD120000_simplify_health_status_values.rb

Create a reversible migration that:

  • UPDATE sourcemon_sources SET health_status = 'working' WHERE health_status IN ('healthy', 'auto_paused', 'unknown')
  • UPDATE sourcemon_sources SET health_status = 'failing' WHERE health_status IN ('warning', 'critical')
  • declining and improving remain unchanged
  • For down: reverse working -> healthy, failing -> critical (best-effort reverse)

Use a timestamp like 20260311120000.

Task 2: Update Source model default health_status

Files: app/models/source_monitor/source.rb

  • Change attribute :health_status, :string, default: "healthy" to attribute :health_status, :string, default: "working"
  • Update the apply_status fallback on line 147: change "healthy" to "working" in source.health_status.presence || "healthy" -- NOTE: this is in source_health_monitor.rb, not in source.rb. Only change the model file here.

Task 3: Run migration on dummy app database

Files: (none -- shell command)

Run cd test/dummy && bin/rails db:migrate to apply the migration to the test database.