class ActiveJob::TrackableGenerator

Generator for generating activerecord migration for the table related to ActiveJob::Trackable::Tracker

invoke with `rails generate active_job:trackable`

Public Class Methods

next_migration_number(dirname) click to toggle source
# File lib/generators/active_job/trackable/trackable_generator.rb, line 15
def self.next_migration_number(dirname)
  next_migration_number = current_migration_number(dirname) + 1

  if ActiveRecord::Base.timestamped_migrations
    [Time.now.utc.strftime('%Y%m%d%H%M%S'), format('%.14d', next_migration_number)].max
  else
    format('%.3d', next_migration_number)
  end
end

Public Instance Methods

create_migration_file() click to toggle source
# File lib/generators/active_job/trackable/trackable_generator.rb, line 25
def create_migration_file
  migration_template 'migration.rb', migration_destination, migration_version: migration_version
end

Private Instance Methods

migration_destination() click to toggle source
# File lib/generators/active_job/trackable/trackable_generator.rb, line 31
def migration_destination
  'db/migrate/create_active_job_trackers.rb'
end
migration_version() click to toggle source
# File lib/generators/active_job/trackable/trackable_generator.rb, line 35
def migration_version
  "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" if ActiveRecord::VERSION::MAJOR >= 5
end