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

Version Path
spree_core-0.70.7 db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
spree_core-0.70.6 db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
apispree_core-0.0.0 db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
My-Commerce_core-1.1.0 db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
My-Commerce_core-1.0.0 db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerceapi-1.0.0 core/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerceapi-1.0.0 dash/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerceapi-1.0.0 api/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerceapi-1.0.0 sandbox/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerceapi-1.0.0 auth/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerceapi-1.0.0 core/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerceapi-1.0.0 promo/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerce-0.0.3 sandbox/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerce-0.0.3 api/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerce-0.0.3 auth/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerce-0.0.3 core/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerce-0.0.3 dash/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerce-0.0.3 promo/spec/test_app/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
MyCommerce-0.0.3 core/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb
rfcommerce_sandbox-0.0.3 db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb