Skip to content

Conversation

@stusherwin
Copy link
Contributor

@stusherwin stusherwin commented Oct 27, 2025

DO NOT MERGE UNTIL DELETE JOB HAS BEEN RUN ON ALL ENVIRONMENTS

Otherwise the migration will fail due to null TRNs

Environments to run job on first

  • Pre-prod
  • Prod
  • Dev
  • TPS sandbox
  • Local dev environments

Context

Once we’ve run the job to delete records without a TRN we should make the TRN column on person non-nullable to ensure no more records are created without a TRN. (It’ll also tidy up our nullable annotations and prevent the need for !s everywhere where we know we have a TRN.)

Changes proposed in this pull request

  • Sets Person.Trn to be non-nullable

Checklist

  • Attach to Trello card
  • Rebased master
  • Cleaned commit history
  • Tested by running locally

@stusherwin stusherwin marked this pull request as draft October 27, 2025 15:47
@stusherwin stusherwin force-pushed the make-trn-non-nullable branch from 15a76d2 to 5a79dd1 Compare October 28, 2025 09:40
@stusherwin stusherwin marked this pull request as ready for review October 28, 2025 09:48
@stusherwin stusherwin marked this pull request as draft October 28, 2025 11:08
@stusherwin stusherwin changed the title Set Person.Trn to be non-nullable Set Person.Trn to be non-nullable [DO NOT MERGE] Oct 28, 2025
@stusherwin stusherwin force-pushed the make-trn-non-nullable branch 2 times, most recently from 3968eb0 to f1e3888 Compare October 28, 2025 18:48
@stusherwin stusherwin marked this pull request as ready for review October 29, 2025 12:58
builder.HasIndex(p => p.DqtContactId).HasFilter("dqt_contact_id is not null").IsUnique();
builder.HasIndex(p => p.MergedWithPersonId).HasFilter("merged_with_person_id is not null");
builder.HasIndex(p => p.Trn).HasFilter("trn is not null").IsUnique();
builder.HasIndex(p => p.Trn).IsUnique();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want an .IsCreatedConcurrently() on this otherwise we might have timeout issues deploying on prod.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right - just looked at postgres docs and it says

Another difference is that a regular CREATE INDEX command can be performed within a transaction block, but CREATE INDEX CONCURRENTLY cannot

Is that going to be an issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to put the CreateIndex into its own migration to mitigate that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the difficulty with this, it might be simpler to leave the index as-is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having potential timeouts on prod seems worrying though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you mean leave the filter in place. Sure can do that

@stusherwin stusherwin force-pushed the make-trn-non-nullable branch from f1e3888 to a1e0e0a Compare October 30, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants