Sha256: 3307639c6f2abb4ec1d5a92b923103312fc71fa23174860204292eeaf721ec28

Contents?: true

Size: 478 Bytes

Versions: 35

Compression:

Stored size: 478 Bytes

Contents

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

35 entries across 35 versions & 3 rubygems

Version Path
spree_core-1.1.0 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_core-1.0.4 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_core-1.1.0.rc2 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_core-1.1.0.rc1 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_pag_seguro-1.0.3 spec/dummy/db/migrate/20120301154067_creditcard_last_four_digits.rb
spree_pag_seguro-1.0.2 spec/dummy/db/migrate/20120301154067_creditcard_last_four_digits.rb
spree_core-1.0.3 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_core-1.0.2 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_core-1.0.1 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_flat_in_range-0.1.0 spec/dummy/db/migrate/20120218160374_creditcard_last_four_digits.rb
spree_core-1.0.0 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_core-1.0.0.rc4 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_core-1.0.0.rc3 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_core-1.0.0.rc2 db/migrate/20091213222815_creditcard_last_four_digits.rb
spree_core-1.0.0.rc1 db/migrate/20091213222815_creditcard_last_four_digits.rb