mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-15 21:56:12 +08:00
17 lines
586 B
Ruby
17 lines
586 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddTeamReferenceToUserAssignments < ActiveRecord::Migration[6.1]
|
|
def up
|
|
add_reference :user_assignments, :team, index: true, foreign_key: true
|
|
UserAssignment.reset_column_information
|
|
|
|
UserAssignment.preload(:assignable).find_each do |user_assignment|
|
|
team = user_assignment.assignable.is_a?(Team) ? user_assignment.assignable : user_assignment.assignable.team
|
|
user_assignment.update_column(:team_id, team.id)
|
|
end
|
|
end
|
|
|
|
def down
|
|
remove_reference :user_assignments, :team, index: true, foreign_key: true
|
|
end
|
|
end
|