Class: OnlineMigrations::BackgroundSchemaMigrations::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/online_migrations/background_schema_migrations/scheduler.rb

Overview

Class responsible for scheduling background schema migrations. It selects a single migration and runs it if there is no currently running migration on the same table.

Scheduler should be configured to run periodically, for example, via cron.

Examples:

Run via whenever

# add this to schedule.rb
every 1.minute do
  runner "OnlineMigrations.run_background_schema_migrations"
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject



17
18
19
# File 'lib/online_migrations/background_schema_migrations/scheduler.rb', line 17

def self.run
  new.run
end

Instance Method Details

#runObject

Runs Scheduler



22
23
24
25
26
27
28
# File 'lib/online_migrations/background_schema_migrations/scheduler.rb', line 22

def run
  migration = find_migration
  if migration
    runner = MigrationRunner.new(migration)
    runner.run
  end
end