osem-fcy/db/migrate/20140625114813_add_week_to_registration.rb
2018-04-04 10:28:10 -07:00

19 lines
442 B
Ruby

# frozen_string_literal: true
class AddWeekToRegistration < ActiveRecord::Migration
class Registration < ApplicationRecord
end
def up
add_column :registrations, :week, :integer
Registration.reset_column_information
Registration.find_each do |registration|
registration.week = registration.created_at.strftime('%W')
registration.save!
end
end
def down
remove_column :registrations, :week
end
end