[17.0][OU-FIX] sms: fill sms_sms.uuid per row before the ORM creates the column#23
Open
eantones wants to merge 1 commit into
Open
[17.0][OU-FIX] sms: fill sms_sms.uuid per row before the ORM creates the column#23eantones wants to merge 1 commit into
eantones wants to merge 1 commit into
Conversation
…the column The uuid field (new in 17.0) has a callable default and a unique constraint, but no migration script fills it for pre-existing rows. The ORM creates the column during the upgrade and evaluates the default once, so every existing row gets the same value and the uuid_unique constraint fails to install. Pre-create the column and backfill a deterministic per-row value (md5 over the id, same 32-hex shape as uuid4().hex). Also breaks any duplicate group left by a previous upgrade run without this script.
eantones
force-pushed
the
17.0-fix-sms-uuid-prefill
branch
from
July 20, 2026 22:29
bad539a to
6df0ec7
Compare
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.
Problem
The
uuidfield onsms.sms(new in 17.0) is declared with a callable default and a unique constraint:The upgrade analysis flags both (
uuid (char): NEW+NEW ir.model.constraint: sms.constraint_sms_sms_uuid_unique), butopenupgrade_scripts/scripts/sms/17.0.3.0/has no migration script. Without one, the ORM creates the missing column during the upgrade and evaluates the callable default once, so every pre-existingsms_smsrow receives the same value and theuuid_uniqueconstraint fails to install:Observed on a real 14.0→18.0 chain: all pre-existing rows ended up sharing one uuid.
Fix
Add
sms/17.0.3.0/pre-migration.py: pre-create the column if missing and backfill a deterministic per-row value (md5over the row id — same 32-hex shape asuuid4().hex). TheWHEREalso breaks any duplicate group left by a previous upgrade run executed without this script, and makes the script idempotent.sms.tracker.sms_uuid(also flagged) needs nothing: the model is new in 17.0, the table is created empty.