Sha256: bf8003ad13fce5801b9d89ba9cd71521111dce3d9dc9fb66baa663108e8ea3a4

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

class AddCreatedByUpdatedByToErpProducts < ActiveRecord::Migration
  def up
    %w{product_feature_types
       product_feature_values
       product_features
       product_offers
       product_types}.each do |table|

      unless column_exists? table.to_sym, :created_by_party_id
        add_column table.to_sym, :created_by_party_id, :integer

        add_index table.to_sym, :created_by_party_id, name: "#{table}_created_by_pty_idx"
      end

      unless column_exists? table.to_sym, :updated_by_party_id
        add_column table.to_sym, :updated_by_party_id, :integer

        add_index table.to_sym, :updated_by_party_id, name: "#{table}_updated_by_pty_idx"
      end

    end

  end

  def down
    %w{product_feature_types
       product_feature_values
       product_features
       product_offers
       product_types}.each do |table|

      if column_exists? table.to_sym, :created_by_party_id
        remove_column table.to_sym, :created_by_party_id
      end

      if column_exists? table.to_sym, :updated_by_party_id
        remove_column table.to_sym, :updated_by_party_id
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
erp_products-4.2.0 db/migrate/20160310163055_add_created_by_updated_by_to_erp_products.rb