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