Class: QC::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



15
16
17
18
# File 'lib/generators/queue_classic/install_generator.rb', line 15

def self.next_migration_number(dirname)
  next_migration_number = current_migration_number(dirname) + 1
  ActiveRecord::Migration.next_migration_number(next_migration_number)
end

Instance Method Details

#create_migration_fileObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/queue_classic/install_generator.rb', line 20

def create_migration_file
  if self.class.migration_exists?('db/migrate', 'add_queue_classic').nil?
    migration_template 'add_queue_classic.rb', 'db/migrate/add_queue_classic.rb'
  end

  if self.class.migration_exists?('db/migrate', 'update_queue_classic_3_0_0').nil?
    migration_template 'update_queue_classic_3_0_0.rb', 'db/migrate/update_queue_classic_3_0_0.rb'
  end

  if self.class.migration_exists?('db/migrate', 'update_queue_classic_3_0_2').nil?
    migration_template 'update_queue_classic_3_0_2.rb', 'db/migrate/update_queue_classic_3_0_2.rb'
  end

  if self.class.migration_exists?('db/migrate', 'update_queue_classic_3_1_0').nil?
    migration_template 'update_queue_classic_3_1_0.rb', 'db/migrate/update_queue_classic_3_1_0.rb'
  end

  if self.class.migration_exists?('db/migrate', 'update_queue_classic_4_0_0').nil?
    migration_template 'update_queue_classic_4_0_0.rb', 'db/migrate/update_queue_classic_4_0_0.rb'
  end
end