class RailsAsyncMigrations::Migration::CheckQueue
Public Class Methods
new()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 5 def initialize end
Public Instance Methods
perform()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 8 def perform Tracer.new.verbose 'Check queue has been triggered' return if has_failures? return if has_on_going? return if no_migration? pending! fire_migration end
Private Instance Methods
created_migration()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 42 def created_migration @created_migration ||= AsyncSchemaMigration.created.first end
current_migration()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 30 def current_migration created_migration end
failed_migration()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 67 def failed_migration @failed_migration ||= AsyncSchemaMigration.failed.first end
fire_migration()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 21 def fire_migration Tracer.new.verbose "Migration `#{current_migration.id}` will now be processed" Workers.new(:fire_migration).perform(current_migration.id) end
has_failures?()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 60 def has_failures? if failed_migration Tracer.new.verbose 'Failing migration blocking the queue, cancelling check' true end end
has_on_going?()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 53 def has_on_going? if pending_migration || processing_migration Tracer.new.verbose 'Another migration under progress, cancelling check' true end end
no_migration?()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 46 def no_migration? unless current_migration Tracer.new.verbose 'No available migration in queue, cancelling check' true end end
pending!()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 26 def pending! current_migration.update state: 'pending' end
pending_migration()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 38 def pending_migration @pending_migration ||= AsyncSchemaMigration.pending.first end
processing_migration()
click to toggle source
# File lib/rails_async_migrations/migration/check_queue.rb, line 34 def processing_migration @processing_migration ||= AsyncSchemaMigration.processing.first end