Add missing CRM_V2 table constraints #404
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eaflood.atlassian.net/browse/WATER-4092
We are migrating the change billing account address functionality from the legacy code to this project. In our test DB, we previously added migrations to recreate the CRM_V2 tables
addresses
,companies
andinvoice_account_addresses
. But to keep things simple we usually don't bother with constraints as unless we really need them, we prefer to avoid using them.Well, in the new Billing Account change address service we're adding we do! 🤦 We depend on the constraints to raise ON CONFLICT errors for our logic to work.
So, in order to test our new service we need to add the missing constraints to our migrations. We're doing that change separately because Add new Billing Account change address service is already pretty big 😬.
When we did apply the constraints it highlighted we had a flaw in our model tests. The top-level
beforeEach()
should only have been cleaning the DB.The model tests also had to be updated to deal with creating 2 invoice address records using the same default data; we can't have multiple records with the same start date and invoice account ID.