Class: AngryBatch::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/angry_batch/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(_dirname) ⇒ Object



10
11
12
# File 'lib/generators/angry_batch/install_generator.rb', line 10

def self.next_migration_number(_dirname)
  Time.now.utc.strftime('%Y%m%d%H%M%S')
end

Instance Method Details

#copy_migrationsObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/angry_batch/install_generator.rb', line 14

def copy_migrations
  existing = self.class.migration_exists?(File.join(destination_root, 'db/migrate'), 'create_angry_batch_tables')

  if existing.nil?
    migration_template 'create_angry_batch_tables.rb', 'db/migrate/create_angry_batch_tables.rb'
    return
  end

  return if File.read(existing).include?('completed_jobs_count')

  migration_template 'add_metadata_and_counters_to_angry_batch_tables.rb', 'db/migrate/add_metadata_and_counters_to_angry_batch_tables.rb', skip: true
end