31 lines
874 B
Ruby
31 lines
874 B
Ruby
class AddReceivedToPPayments < ActiveRecord::Migration[6.0]
|
|
def change
|
|
add_column :p_payments, :received_at, :date
|
|
add_column :p_payments, :past_paid_at, :date
|
|
add_column :p_payments, :past_theo_date, :date
|
|
add_column :p_payments, :past_diff, :boolean
|
|
add_reference :p_payments, :p_bank_account, index: true, foreign_key: true
|
|
|
|
|
|
|
|
PPayment.where("theo_date is not null").order(:p_payment_type_id).each do |pp|
|
|
|
|
if pp.theo_date != pp.paid_at
|
|
puts "TEST"
|
|
pp.past_theo_date = pp.theo_date
|
|
pp.past_paid_at = pp.paid_at
|
|
|
|
pp.received_at = pp.paid_at
|
|
pp.paid_at = pp.theo_date
|
|
|
|
puts pp.save
|
|
end
|
|
end
|
|
|
|
#PPayment.where(:p_payment_type_id => 4).update_all(:p_payment_type_id => 41, :past_diff => true)
|
|
#.update_all(:p_payment_type_id => 4)
|
|
|
|
|
|
end
|
|
end
|