Class: CircuitSwitch::MigrationGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/circuit_switch/migration_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_migrationObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/circuit_switch/migration_generator.rb', line 11

def generate_migration
  case migration_type
  when ['add_key']
    migration_template 'add_key.rb.erb', 'db/migrate/add_key_to_circuit_switches.rb', migration_version: migration_version
  when ['make_key_unique']
    migration_template 'make_key_unique.rb.erb', 'db/migrate/make_key_unique_for_circuit_switches.rb', migration_version: migration_version
  else
    migration_template 'migration.rb.erb', 'db/migrate/create_circuit_switches.rb', migration_version: migration_version
  end
end

#migration_versionObject



22
23
24
25
26
# File 'lib/generators/circuit_switch/migration_generator.rb', line 22

def migration_version
  if ActiveRecord::VERSION::MAJOR >= 5
    "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
  end
end