Fix failing migration for new price and currency columns of ticket
This commit is contained in:
parent
fa5b5242c1
commit
0911e1ed83
1 changed files with 11 additions and 9 deletions
|
|
@ -9,16 +9,18 @@ class SplitTicketPriceInPriceAndCurrency < ActiveRecord::Migration
|
||||||
|
|
||||||
TempTicket.all.each do |ticket|
|
TempTicket.all.each do |ticket|
|
||||||
# Replace currency symbol with ISO Code
|
# Replace currency symbol with ISO Code
|
||||||
ticket.ticket_price.gsub!('€', 'EUR')
|
if ticket.ticket_price
|
||||||
ticket.ticket_price.gsub!('$', 'USD')
|
ticket.ticket_price.gsub!('€', 'EUR')
|
||||||
ticket.ticket_price.gsub!('£', 'GBP')
|
ticket.ticket_price.gsub!('$', 'USD')
|
||||||
ticket.ticket_price.gsub!('¥', 'CNY')
|
ticket.ticket_price.gsub!('£', 'GBP')
|
||||||
ticket.ticket_price.gsub!('₹', 'INR')
|
ticket.ticket_price.gsub!('¥', 'CNY')
|
||||||
|
ticket.ticket_price.gsub!('₹', 'INR')
|
||||||
|
|
||||||
money = ticket.ticket_price.to_money
|
money = ticket.ticket_price.to_money
|
||||||
ticket.price_cents = money.cents
|
ticket.price_cents = money.cents
|
||||||
ticket.price_currency = money.currency_as_string
|
ticket.price_currency = money.currency_as_string
|
||||||
ticket.save
|
ticket.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_column :tickets, :ticket_price
|
remove_column :tickets, :ticket_price
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue