class OnlineMigrations::BackgroundMigrations::MigrationStatusValidator
@private
Constants
- VALID_STATUS_TRANSITIONS
Public Instance Methods
validate(record)
click to toggle source
# File lib/online_migrations/background_migrations/migration_status_validator.rb, line 31 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 from status #{previous_status} to #{new_status}" ) end end