-
Notifications
You must be signed in to change notification settings - Fork 126
Feat(multientities): data fix for billing entitiy sequential id on invoices #3820
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
Merged
annvelents
merged 6 commits into
main
from
feat/multientities/uniqueness_fix_for_billing_entitiy_sequential_id
Jun 26, 2025
Merged
Feat(multientities): data fix for billing entitiy sequential id on invoices #3820
annvelents
merged 6 commits into
main
from
feat/multientities/uniqueness_fix_for_billing_entitiy_sequential_id
Jun 26, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6079048
to
e900b65
Compare
annvelents
commented
Jun 12, 2025
db/migrate/20250611083925_fix_stale_billing_entity_sequential_id_to_be_uniq.rb
Outdated
Show resolved
Hide resolved
e900b65
to
5aeeb61
Compare
ancorcruz
approved these changes
Jun 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work.
db/migrate/20250611083925_fix_stale_billing_entity_sequential_id_to_be_uniq.rb
Outdated
Show resolved
Hide resolved
db/migrate/20250611083925_fix_stale_billing_entity_sequential_id_to_be_uniq.rb
Show resolved
Hide resolved
db/migrate/20250611083925_fix_stale_billing_entity_sequential_id_to_be_uniq.rb
Show resolved
Hide resolved
db/migrate/20250611083925_fix_stale_billing_entity_sequential_id_to_be_uniq.rb
Outdated
Show resolved
Hide resolved
db/migrate/20250611083925_fix_stale_billing_entity_sequential_id_to_be_uniq.rb
Outdated
Show resolved
Hide resolved
vincent-pochet
approved these changes
Jun 13, 2025
8bf66a9
to
ccef0a6
Compare
diegocharles
pushed a commit
that referenced
this pull request
Jun 30, 2025
…voices (#3820) ## Context We tried to introduce the uniqueness index on billing_entity_sequential_id, but we populated this value with organization_sequential_id, and inherited some old duplicated organization_sequential_id (invoices created before april 2024) So now we want to update the historical data to be able to introduce the uniqueness index ## Description Added a migration that: 1) updates all invoices related to billing_entity with document_numbering "per_customer" with duplicated billing_entity_sequential_id to have billing_entity_sequential_id = nil 2) goes through all billing entities with numbering per entity, finds invoices with duplicated billing_entity_sequential_id and updates it to nil, if in the database a value already exist with bigger billing_entity_sequential_id 3) if latest billing_entity_sequential_id is duplicated - means something went completely wrong, we want to manually investigate it Note that just updating all invoices except one with maximum billing_entity_sequential_id to have nil is easier, but this way we'd erase a lot of correct data + loose information in case we want to investigate something, so it was decided to proceed with selective update
diegocharles
pushed a commit
that referenced
this pull request
Jul 11, 2025
…voices (#3820) We tried to introduce the uniqueness index on billing_entity_sequential_id, but we populated this value with organization_sequential_id, and inherited some old duplicated organization_sequential_id (invoices created before april 2024) So now we want to update the historical data to be able to introduce the uniqueness index Added a migration that: 1) updates all invoices related to billing_entity with document_numbering "per_customer" with duplicated billing_entity_sequential_id to have billing_entity_sequential_id = nil 2) goes through all billing entities with numbering per entity, finds invoices with duplicated billing_entity_sequential_id and updates it to nil, if in the database a value already exist with bigger billing_entity_sequential_id 3) if latest billing_entity_sequential_id is duplicated - means something went completely wrong, we want to manually investigate it Note that just updating all invoices except one with maximum billing_entity_sequential_id to have nil is easier, but this way we'd erase a lot of correct data + loose information in case we want to investigate something, so it was decided to proceed with selective update
diegocharles
pushed a commit
that referenced
this pull request
Jul 11, 2025
…voices (#3820) We tried to introduce the uniqueness index on billing_entity_sequential_id, but we populated this value with organization_sequential_id, and inherited some old duplicated organization_sequential_id (invoices created before april 2024) So now we want to update the historical data to be able to introduce the uniqueness index Added a migration that: 1) updates all invoices related to billing_entity with document_numbering "per_customer" with duplicated billing_entity_sequential_id to have billing_entity_sequential_id = nil 2) goes through all billing entities with numbering per entity, finds invoices with duplicated billing_entity_sequential_id and updates it to nil, if in the database a value already exist with bigger billing_entity_sequential_id 3) if latest billing_entity_sequential_id is duplicated - means something went completely wrong, we want to manually investigate it Note that just updating all invoices except one with maximum billing_entity_sequential_id to have nil is easier, but this way we'd erase a lot of correct data + loose information in case we want to investigate something, so it was decided to proceed with selective update
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
We tried to introduce the uniqueness index on billing_entity_sequential_id, but we populated this value with organization_sequential_id, and inherited some old duplicated organization_sequential_id (invoices created before april 2024)
So now we want to update the historical data to be able to introduce the uniqueness index
Description
Added a migration that:
Note that just updating all invoices except one with maximum billing_entity_sequential_id to have nil is easier, but this way we'd erase a lot of correct data + loose information in case we want to investigate something, so it was decided to proceed with selective update