2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2014-06-25 14:58:33 +02:00
|
|
|
class AddWeekToEvent < ActiveRecord::Migration
|
|
|
|
|
class Event < ActiveRecord::Base
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def up
|
|
|
|
|
add_column :events, :week, :integer
|
|
|
|
|
Event.reset_column_information
|
|
|
|
|
Event.find_each do |event|
|
|
|
|
|
event.week = event.created_at.strftime('%W')
|
|
|
|
|
event.save!
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def down
|
|
|
|
|
remove_column :events, :week
|
|
|
|
|
end
|
|
|
|
|
end
|