Sha256: 9a55e24f4420d57c6e599dd9c50062a585c006edd8c152ba233a5c46d54ec5b7
Contents?: true
Size: 836 Bytes
Versions: 25
Compression:
Stored size: 836 Bytes
Contents
# frozen_string_literal: true # This migration comes from spree (originally 20160420181916) class MigrateCreditCardsToWalletPaymentSources < ActiveRecord::Migration[4.2] class CreditCard < ActiveRecord::Base self.table_name = 'spree_credit_cards' end class WalletPaymentSource < ActiveRecord::Base self.table_name = 'spree_wallet_payment_sources' end def up credit_cards = CreditCard. where.not(gateway_customer_profile_id: nil). where.not(user_id: nil) credit_cards.find_each do |credit_card| WalletPaymentSource.find_or_create_by!( user_id: credit_card.user_id, payment_source_id: credit_card.id, payment_source_type: 'Spree::CreditCard' ) do |wallet_source| wallet_source.default = credit_card.default end end end def down end end
Version data entries
25 entries across 25 versions & 9 rubygems