Sha256: ff952f7b3c866e160a519065839e1f421fe9906c26e87b00ac89d2c1e2486301

Contents?: true

Size: 956 Bytes

Versions: 1

Compression:

Stored size: 956 Bytes

Contents

class AddCreatedByUpdatedByToErpTxnsAndAccts < ActiveRecord::Migration
  def up
    %w{biz_txn_acct_roots biz_txn_events}.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{biz_txn_acct_roots biz_txn_events}.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_txns_and_accts-4.2.0 db/migrate/20160310163051_add_created_by_updated_by_to_erp_txns_and_accts.rb