[MODINVOICE-647] Updated models + new migration#623
Merged
Conversation
9 tasks
Contributor
|
Did you had the chance to test if with our CLI's upgrade module command? |
10 tasks
Contributor
Author
Not yet, I will try. |
| SELECT po.id, COALESCE(MAX(REGEXP_REPLACE(pol.jsonb ->> 'poLineNumber', '^[^-]+-([^-])$', '\1')::int), 0) + 1 AS number | ||
| FROM ${myuniversity}_${mymodule}.purchase_order po | ||
| LEFT JOIN ${myuniversity}_${mymodule}.po_line pol ON pol.purchaseOrderId = po.id | ||
| WHERE po.jsonb -> 'nextPolNumber' IS NULL |
Contributor
There was a problem hiding this comment.
Do you think po.jsonb ? 'nextPolNumber' would have any benefits?
Contributor
Author
There was a problem hiding this comment.
we would have to use NOT; might as well use IS NULL, which I have tested successfully (I doubt it makes a difference in performance)
BKadirkhodjaev
approved these changes
May 13, 2026
SerhiiNosko
reviewed
May 14, 2026
| @@ -0,0 +1,14 @@ | |||
| <#if mode.name() == "UPDATE"> | |||
| WITH missing_next_numbers AS ( | |||
| SELECT po.id, COALESCE(MAX(REGEXP_REPLACE(pol.jsonb ->> 'poLineNumber', '^[^-]+-([^-])$', '\1')::int), 0) + 1 AS number | |||
Contributor
There was a problem hiding this comment.
([^-]) without + matches exactly 1 character. So migration can fail for po line numbers >=10
|
SerhiiNosko
approved these changes
May 14, 2026
This was referenced May 15, 2026
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
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.



Purpose
MODINVOICE-647 - Invoice line number is reused after deletion
Approach
nextPolNumberRelated PRs
Pre-Review Checklist