Sha256: c3abfb2629240339af954446c5abda3bb3eb653ee61b2fc9c5858151eea77741
Contents?: true
Size: 683 Bytes
Versions: 45
Compression:
Stored size: 683 Bytes
Contents
class AssignCreditcardTxnsToPayment < ActiveRecord::Migration def self.up add_column "creditcard_txns", "payment_id", :integer ActiveRecord::Base.connection.select_all("SELECT * FROM creditcard_txns").each do |txn_attrs| if creditcard = Creditcard.find_by_id(txn_attrs["creditcard_id"]) and creditcard.payments.first execute "UPDATE creditcard_txns SET payment_id = #{creditcard.payments.first.id} WHERE id = #{txn_attrs['id']}" end end remove_column "creditcard_txns", "creditcard_payment_id" end def self.down remove_column "creditcard_txns", "payment_id" add_column "creditcard_txns", "creditcard_payment_id", :integer end end
Version data entries
45 entries across 33 versions & 8 rubygems