class OnlineMigrations::BackgroundMigrations::MigrationJobStatusValidator
@private
Constants
- VALID_STATUS_TRANSITIONS
Public Instance Methods
validate(record)
click to toggle source
# File lib/online_migrations/background_migrations/migration_job_status_validator.rb, line 13 def validate(record) return unless record.status_changed? previous_status, new_status = record.status_change valid_new_statuses = VALID_STATUS_TRANSITIONS.fetch(previous_status, []) unless valid_new_statuses.include?(new_status) record.errors.add( :status, "cannot transition background migration job from status #{previous_status} to #{new_status}" ) end end