Sha256: c5742dd885825ff2a8c3ddd86e93fbbcad889bdce3f73ae386e4529d14165a4e

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

class AddCreatedByUpdatedByToErpOrders < ActiveRecord::Migration
  def up
    %w{charge_lines order_line_items}.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{charge_lines order_line_items}.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_orders-4.2.0 db/migrate/20160310163060_add_created_by_updated_by_to_erp_orders.rb