Class: Bowline::Generators::MigrationGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/bowline/generators/migration.rb

Instance Method Summary collapse

Methods inherited from Generator

chmod, #shebang, source_root, touch, #with_modules

Instance Method Details

#class_nameObject



16
17
18
# File 'lib/bowline/generators/migration.rb', line 16

def class_name
  "#{self.name.camel_case}Migration"
end

#file_nameObject



24
25
26
# File 'lib/bowline/generators/migration.rb', line 24

def file_name
  "#{version}_#{migration_name}_migration"
end

#migration_nameObject



20
21
22
# File 'lib/bowline/generators/migration.rb', line 20

def migration_name
  self.name.snake_case
end

#table_nameObject



12
13
14
# File 'lib/bowline/generators/migration.rb', line 12

def table_name
  self.name.snake_case.pluralize
end

#versionObject



28
29
30
31
32
# File 'lib/bowline/generators/migration.rb', line 28

def version
  # TODO: handle ActiveRecord timestamped migrations
  n = options[:delete] ? current_migration_nr : current_migration_nr + 1
  format("%03d", n)
end