Sha256: e14ba98440bb581438c72ae1ff167dabeafacd6411852151b29e7f0dc8844c94

Contents?: true

Size: 540 Bytes

Versions: 7

Compression:

Stored size: 540 Bytes

Contents

# This migration comes from spree (originally 20091213222815)
class CreditcardLastFourDigits < ActiveRecord::Migration
  def up
    rename_column :creditcards, :display_number, :last_digits

    creditcards = select_all "SELECT * FROM creditcards"
    creditcards.each do |card|
      execute "UPDATE creditcards SET last_digits = '#{card['last_digits'].gsub('XXXX-XXXX-XXXX-', '')}' WHERE id = #{card['id']}" if card['last_digits'].present?
    end
  end

  def down
    rename_column :creditcards, :last_digits, :display_number
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
spree_mercado_pago_payment_method-0.0.2 spec/dummy/db/migrate/20121121030156_creditcard_last_four_digits.spree.rb
spree_mercado_pago_payment_method-0.1.1 spec/dummy/db/migrate/20121121030156_creditcard_last_four_digits.spree.rb
spree_mercado_pago_payment_method-0.1.0 spec/dummy/db/migrate/20121121030156_creditcard_last_four_digits.spree.rb
datashift_spree-0.3.0 spec/sandbox/db/migrate/20121023154375_creditcard_last_four_digits.spree.rb
datashift_spree-0.2.1 spec/sandbox/db/migrate/20121015151168_creditcard_last_four_digits.spree.rb
datashift_spree-0.2.0 spec/sandbox/db/migrate/20120925192736_creditcard_last_four_digits.spree.rb
datashift_spree-0.1.0 spec/sandbox/db/migrate/20120918081467_creditcard_last_four_digits.spree.rb