Sha256: ed3c266a4e342896339eb212cb47a94be58fb7c59faa658b60bfe12c7b184f47

Contents?: true

Size: 1.25 KB

Versions: 64

Compression:

Stored size: 1.25 KB

Contents

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

      desc "Upgrade effective_orders from the 0.3.x branch"

      source_root File.expand_path("../../templates", __FILE__)

      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
        @orders_table_name = ':' + EffectiveOrders.orders_table_name.to_s
        @order_items_table_name = ':' + EffectiveOrders.order_items_table_name.to_s
        @carts_table_name = ':' + EffectiveOrders.carts_table_name.to_s
        @cart_items_table_name = ':' + EffectiveOrders.cart_items_table_name.to_s
        @customers_table_name = ':' + EffectiveOrders.customers_table_name.to_s
        @subscriptions_table_name = ':' + EffectiveOrders.subscriptions_table_name.to_s

        migration_template '../../../db/upgrade/02_upgrade_effective_orders_from03x.rb.erb', 'db/migrate/upgrade_effective_orders_from03x.rb'
      end

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

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
effective_orders-1.1.2 lib/generators/effective_orders/upgrade_from03x_generator.rb
effective_orders-1.1.1 lib/generators/effective_orders/upgrade_from03x_generator.rb
effective_orders-1.1.0 lib/generators/effective_orders/upgrade_from03x_generator.rb
effective_orders-1.0.0 lib/generators/effective_orders/upgrade_from03x_generator.rb