scinote-web/db/migrate/20180416114040_add_team_id_to_reports.rb

13 lines
318 B
Ruby

class AddTeamIdToReports < ActiveRecord::Migration[5.1]
def up
add_reference :reports, :team, index: true
Report.preload(:project).find_each do |report|
team_id = report.project.team_id
report.update_column(:team_id, team_id)
end
end
def down
remove_column :reports, :team
end
end