Class: MasterDataTool::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/master_data_tool/install/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/master_data_tool/install/install_generator.rb', line 10

def self.next_migration_number(dirname)
  ::ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#create_migration_fileObject



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

def create_migration_file
  migration_dir = File.expand_path("db/migrate")
  template = 'create_master_data_statuses'

  if self.class.migration_exists?(migration_dir, template)
    ::Kernel.warn "Migration already exists: #{template}"
  else
    migration_template(
      "#{template}.rb.erb",
      "db/migrate/#{template}.rb",
      migration_version: migration_version
    )
  end
end