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

- (Object) class_name



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

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

- (Object) file_name



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

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

- (Object) migration_name



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

def migration_name
  self.name.snake_case
end

- (Object) table_name



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

def table_name
  self.name.snake_case.pluralize
end

- (Object) version



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