Setting alias_id on the actor profile when merging, to ensure the actor name for that entity is still associated.

This commit is contained in:
2026-11-30 22:11:23 +01:00
parent 0a4f7bd9ba
commit 13f0f48e53
+10 -2
View File
@@ -899,6 +899,10 @@ export async function mergeActors(targetActorId, sourceActorIds, comment, reqUse
.update('alias_for', targetActorId)
.whereIn('id', sourceActorIds)
.returning(['id', 'alias_for']),
// aliases of the source actors become aliases of the target, so they aren't chained
trx('actors')
.update('alias_for', targetActorId)
.whereIn('alias_for', sourceActorIds),
trx('actors_avatars')
.update('actor_id', targetActorId)
.whereIn('actor_id', sourceActorIds),
@@ -912,8 +916,12 @@ export async function mergeActors(targetActorId, sourceActorIds, comment, reqUse
const duplicateSourceProfiles = sourceProfiles.filter((profile) => newestSourceProfileMap[profile.entity_id] && newestSourceProfileMap[profile.entity_id] !== profile.id);
// assign source actor profiles to target actor, unless a profile for that entity is already present
// the alias records the name the profile was found under, a profile that already had one keeps it
mergedProfiles = await trx('actors_profiles')
.update('actor_id', targetActorId)
.update({
actor_id: targetActorId,
alias_id: knex.raw('coalesce(alias_id, actor_id)'),
})
.whereIn('actor_id', sourceActorIds)
.whereNotIn('entity_id', existingProfiles.map((profile) => profile.entity_id))
.whereNotIn('id', duplicateSourceProfiles.map((profile) => profile.id))
@@ -948,7 +956,7 @@ export async function mergeActors(targetActorId, sourceActorIds, comment, reqUse
mergedSceneActors = await trx('releases_actors')
.update({
actor_id: targetActorId,
alias_id: knex.raw('actor_id'),
alias_id: knex.raw('coalesce(alias_id, actor_id)'), // keep the credited name when the source actor was credited by its own alias
})
.whereIn('actor_id', sourceActorIds)
.returning('release_id');