seek
seek copied to clipboard
Merge accounts
Adds methods and tests to be able to merge two accounts, transferring all the relevant associations without duplication.
Resolves #1666.
Maybe useful:
List of tables that reference user_id
:
api_tokens
assay_auth_lookup
asset_doi_logs
collection_auth_lookup
data_file_auth_lookup
document_auth_lookup
event_auth_lookup
favourite_groups
favourites
file_template_auth_lookup
identities
investigation_auth_lookup
model_auth_lookup
moderatorships
oauth_sessions
placeholder_auth_lookup
presentation_auth_lookup
publication_auth_lookup
resource_publish_logs
sample_auth_lookup
saved_searches
sop_auth_lookup
strain_auth_lookup
study_auth_lookup
template_auth_lookup
workflow_auth_lookup
List of tables that reference person_id
:
admin_defined_role_programmes
admin_defined_role_projects
disciplines_people
favourite_group_memberships
group_memberships
project_subscriptions
publication_authors
roles
subscriptions
users
Just some notes on the comment above:
Person:
The roles
, admin_defined_role_programmes
, admin_defined_role_projects
, group_memberships
, subsriptions
and users
are already included.
For favourite_group_memberships
, project_subscriptions
and publication_authors
, this needs to be added in the main merge method:
merge_associations(other_person, 'favourite_group_memberships',
%i[favourite_group_id access_type], { person_id: id })
merge_associations(other_person, 'project_subscriptions',
%i[project_id unsubscribed_types frequency], { person_id: id })
merge_associations(other_person, 'publication_authors',
%i[first_name last_name publication_id author_index], { person_id: id })
with accompanying tests.
For disciplines_people
I am unsure... the method person.disciplines
bounces off the Disciplines
table...
User:
Identities are already included.
For api_tokens
, favourite_groups
and oauth_sessions
this can be added in the merge_user
method:
merge_user_associations(other_person, 'api_tokens',
%i[title], { user_id: user.id })
merge_user_associations(other_person, 'favourite_groups',
%i[name], { user_id: user.id })
merge_user_associations(other_person, 'oauth_sessions',
%i[provider], { user_id: user.id })
with accompanying tests.
For asset_doi_logs
, favourites
, moderatorships
, resource_publish_logs
and saved_searches
I am not sure.