Skip to content

Make Statement#contract_id mandatory#2274

Open
ethax-ross wants to merge 1 commit intomainfrom
require-contract-id
Open

Make Statement#contract_id mandatory#2274
ethax-ross wants to merge 1 commit intomainfrom
require-contract-id

Conversation

@ethax-ross
Copy link
Collaborator

Context

We are now migrating contracts and populate the contract on all statements (in both seed data and the data migration), so we want to make contract mandatory with validation and non-nullable foreign key.

As we can reach ActiveLeadProvider via Statement#contract we no longer need to reference Statement#active_lead-provider directly and can remove it.

Changes proposed in this pull request

Update the contract_id to be not-nullable and add required validation.

Remove Statement#active_lead_provider_id as this is now redundant (we can get the active_lead_provider via the contract).

Change Statement uniqueness validation to work through contract.active_lead_provider.

Update all references in specs.

Guidance to review

Now that Statement doesn't have a direct association to ActiveLeadProvider we can't enforce uniqueness (of month/year/active lead provider) at the database level. We weren't doing this previously anyway, but it is something we could have done and no longer can without the direct reference in place (there can be multiple contracts for an ActiveLeadProvider).

@github-actions
Copy link

Review app deployed to https://cpd-ec2-review-2274-web.test.teacherservices.cloud

Update the `contract_id` to be not-nullable and add required validation.

Remove `Statement#active_lead_provider_id` as this is now redundant (we can get
the `active_lead_provider` via the `contract`).

Change `Statement` uniqeness validation to work through
`contract.active_lead_provider`.

Update all references in specs.
@sonarqubecloud
Copy link

@ethax-ross ethax-ross marked this pull request as ready for review February 18, 2026 09:24
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