Skip to content

Updating Depositors

Adam Wead edited this page Nov 3, 2020 · 2 revisions

Run the depositor's report outlined in migration and examine the report for Agent records that need to be linked to a given User.

Updating an Agent

To update a given Agent with its Penn State id:

Agent.find(id).update(psu_id: psu_id)

Merging Agents

If there are two Agent records for a single depositor, you can merge the two by moving any aliases from the other record over to the principal one.

def merge_agents(principal_id, other_id)
  Agent.find(other_id).alias_ids.map do |id|
    Alias.find(id).update(agent_id: principal_id)
  end
end

To merge the two records:

merge_agents(agent_id, duplicate_agent_id)

Then, update the right agent with the Penn State id, if needed:

Agent.find(agent_id).update(psu_id: psu_id)

There is no need to remove the other Agent, these records will simply not be migrated.

Clone this wiki locally