Sha256: 70db2d5a933d0a6d8b7221b5ed1840c0ef92526106ad598f876ae09b39f45db8

Contents?: true

Size: 1.04 KB

Versions: 83

Compression:

Stored size: 1.04 KB

Contents

# bundle exec rails generate effective_orders:upgrade_price_column TABLE COLUMN

module EffectiveOrders
  module Generators
    class UpgradePriceColumn < Rails::Generators::Base
      include Rails::Generators::Migration

      desc "Upgrade a table with a decimal column to integer"

      source_root File.expand_path("../../templates", __FILE__)
      argument :table, :type => :string, :default => nil
      argument :column, :type => :string, :default => :price

      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

      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

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

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
effective_orders-2.1.17 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.16 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.15 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.14 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.13 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.12 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.10 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.9 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.8 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.7 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.6 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.5 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.4 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.3 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.2 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.1 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.1.0 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.0.1 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-2.0.0 lib/generators/effective_orders/upgrade_price_column_generator.rb
effective_orders-1.8.1 lib/generators/effective_orders/upgrade_price_column_generator.rb