Add 'week' column to TicketPurchases

This commit is contained in:
AEtherC0r3 2017-04-19 16:47:59 +03:00 committed by Stella Rouzi
parent 9ff3601453
commit c2184c1c4f
3 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1,15 @@
class AddWeekToTicketPurchases < ActiveRecord::Migration
class TmpTicketPurchase < ActiveRecord::Base
self.table_name = 'ticket_purchases'
end
def change
add_column :ticket_purchases, :week, :integer
TmpTicketPurchase.reset_column_information
TmpTicketPurchase.find_each do |purchase|
purchase.week = purchase.created_at ? purchase.created_at.strftime('%W') : 0
purchase.save!
end
end
end