Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce actor name entity #1669

Open
1 of 7 tasks
elsand opened this issue Jan 9, 2025 · 0 comments
Open
1 of 7 tasks

Introduce actor name entity #1669

elsand opened this issue Jan 9, 2025 · 0 comments
Labels
performance Issue related to performance

Comments

@elsand
Copy link
Member

elsand commented Jan 9, 2025

Introduction

In order to reduce Postgre disk usage, we want to normalize the actor names into a separate table

Description

Actors carry a lot of duplication, as the name of the actor is resolved immediately and stored in full. A new approach will introduce a "ActorName" entity/table, which is referred to by id from each actor object within a dialog aggregate.

Name resolution should still happen immediately, but instead of storing the result to the actor-entity directly, a lookup for that identifier/name pair is performed, and if it matches, a reference to that existing actor name is stored into the actor object. If no match is found (either the actor is previously unseen, or has changed name), a new entry is stored and referred to by the actor object. This will effectively normalize the name property of the actor entity, while maintaining immutability with regards to name changing etc.

This should not have any effect on DTOs, ie not change the API contract for endusers/serviceowners.

#387 is still relevant, but out of scope for this issue.

Implementation

We need to convert existing actor name entries to the new table, so a migration script must be made that perform this, ie takes the existing actorid/name and adds (if not already existing) a corresponding entry in the new table which is referred.

We cannot remove ActorName (the string) from the entity in this PR, as all database changes must be made backwards compatible with currently running code. A separate issue should be made to clean up this after conversion has been made and the new version of the code fully deployed and deemed stable.

Tasks

Preview Give feedback

Threat modelling

Preview Give feedback

Acceptance criteria

GIVEN an actor is being created/updated with a name that already exists in the new ActorName table
WHEN the system processes the actor's name
THEN the existing actor name entry is reused, and the actor entity is set to reference the existing ActorNameId

GIVEN an actor is being created/updated with a name that does not exist in the new ActorName table
WHEN the system processes the actor's name
THEN a new entry is created in the ActorName table, and the actor entity is set to reference the new ActorNameId

GIVEN existing actor entities still store full names directly
WHEN the migration script is run
THEN each actor's name is converted and matched to an new/existing entry in the new ActorName table, and the Actor entity is updated to reference the corresponding ActorNameId

GIVEN the DTO contract must remain unchanged
WHEN the new design is deployed
THEN public or external APIs continue returning actor names as before, with no contract changes for consumers

GIVEN legacy code running against the database
WHEN the database changes for the new ActorName table are applied
THEN no breaking changes are introduced, and both old and new code can continue to function during the transition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Issue related to performance
Projects
Development

No branches or pull requests

1 participant