Sha256: 1b1e4319309d4ca058e03badd7a77ea4b22cc1d70235ca19ac76990e3febe0e1

Contents?: true

Size: 973 Bytes

Versions: 2

Compression:

Stored size: 973 Bytes

Contents

class AddCreatedByUpdatedByToErpInvoicing < ActiveRecord::Migration
  def up
    %w{invoices invoice_items payment_applications}.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{invoices invoice_items payment_applications}.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

2 entries across 2 versions & 1 rubygems

Version Path
erp_invoicing-4.2.0 db/migrate/20160310163059_add_created_by_updated_by_to_erp_invoicing.rb
erp_invoicing-4.1.0 db/migrate/20160310163059_add_created_by_updated_by_to_erp_invoicing.rb