feat: added column type change migration#3208
Open
dankgarlic1 wants to merge 8 commits intofrappe:developfrom
Open
feat: added column type change migration#3208dankgarlic1 wants to merge 8 commits intofrappe:developfrom
dankgarlic1 wants to merge 8 commits intofrappe:developfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3208 +/- ##
===========================================
- Coverage 57.17% 57.13% -0.05%
===========================================
Files 128 128
Lines 6167 6170 +3
===========================================
- Hits 3526 3525 -1
- Misses 2641 2645 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
96c32e6 to
e4404e9
Compare
dankgarlic1
commented
Apr 15, 2026
Comment on lines
+36
to
+46
| yearly_max_data = frappe.db.sql( | ||
| """ | ||
| SELECT | ||
| SUBSTRING(name, 8, 4) as year, | ||
| MAX(CAST(RIGHT(name, 5) AS UNSIGNED)) as max_id | ||
| FROM `tabHD Ticket` | ||
| WHERE name LIKE 'HD-TKT-____-_____' | ||
| GROUP BY year | ||
| """, | ||
| as_dict=True, | ||
| ) |
Contributor
Author
There was a problem hiding this comment.
The series seeding logic looks a bit less readable and ugly, but I thought if I did it in Python the OOM could happen. Not sure what kind of volumes the Helpdesk users have, so I went with SQL to keep the RAM safe
2 tasks
Contributor
Author
|
@RitvikSardana please take a look at this |
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.
Moving the ticket naming system from simple auto-incrementing integers to a structured, year-based format: HD-TKT-YYYY-#####.
The Architectural Approach
I split this into a two-phase migration to ensure the database stays stable:
Phase 1: Schema Alignment
The first patch converts the name column from BigInt to VarChar. Since we are moving from numbers to strings, the "pipe" had to be widened first before we could push any new data through.
Phase 2: Data Transformation & Seeding
The second patch handles the heavy lifting:
Backfilling: It iterates through legacy tickets and renames them to the new format based on their original creation year.
Series Recovery: It calculates the highest existing ID for each year to seed the tabSeries table. This ensures the next ticket created in the UI follows the sequence perfectly without crashing.
Performance Note
For the series seeding, the logic looks a bit less readable and ugly, but I thought if I did it in Python the OOM could happen. Not sure what kind of volumes the Helpdesk users have, so I went with SQL to keep the RAM safe by letting the DB handle the grouping and max-ID calculations.
fixes #3207