Sha256: 1b54b768a5251758b4e32efa603347c93027c5c663b43a7578a9b1b1bd40c3b3
Contents?: true
Size: 887 Bytes
Versions: 4
Compression:
Stored size: 887 Bytes
Contents
# This migration comes from spree (originally 20100214212536) class AssignCreditcardTxnsToPayment < ActiveRecord::Migration def up add_column :creditcard_txns, :payment_id, :integer # Temporarily set back to creditcards Spree::Creditcard.table_name = 'creditcards' ActiveRecord::Base.connection.select_all('SELECT * FROM creditcard_txns').each do |txn_attrs| if creditcard = Spree::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 Spree::Creditcard.table_name = 'spree_creditcards' remove_column :creditcard_txns, :creditcard_payment_id end def down remove_column :creditcard_txns, :payment_id add_column :creditcard_txns, :creditcard_payment_id, :integer end end
Version data entries
4 entries across 4 versions & 1 rubygems