Class: EffectiveOrders::Generators::UpgradePriceColumn

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/generators/effective_orders/upgrade_price_column_generator.rb', line 14

def self.next_migration_number(dirname)
  if not ActiveRecord::Base.timestamped_migrations
    Time.new.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#create_migration_fileObject



22
23
24
25
26
27
# File 'lib/generators/effective_orders/upgrade_price_column_generator.rb', line 22

def create_migration_file
  @table = table.to_s.downcase
  @column = column.to_s.downcase

  migration_template '../../../db/upgrade/upgrade_price_column_on_table.rb.erb', "db/migrate/upgrade_price_column_on_#{table}.rb"
end

#show_readmeObject



29
30
31
# File 'lib/generators/effective_orders/upgrade_price_column_generator.rb', line 29

def show_readme
  readme "README" if behavior == :invoke
end