fix: repair SQL_ASCII signature encoding

This commit is contained in:
hectorzhao
2026-07-22 18:51:02 +08:00
parent 344003e034
commit e28288f691
4 changed files with 30 additions and 0 deletions
@@ -0,0 +1,19 @@
-- The previous bracket-normalization migration ran against a legacy SQL_ASCII
-- database. PostgreSQL treated the UTF-8 bracket regexp as individual bytes and
-- removed the trailing 0x91 byte from the final Chinese character in two known
-- signatures. Restore only the rows whose primary key and corrupt byte sequence
-- both match the pre-migration backup, so later user edits cannot be overwritten.
UPDATE "SmsSignature"
SET name = convert_from(
decode('e38090e888aae5a4a9e4bfa1e681afe4bfa1e8afbae7bd91e38091', 'hex'),
'SQL_ASCII'
)
WHERE id IN (
'cmrj2ci1r00544pnkt64wza4e',
'cmrobgqp7002nwenke5wh09fr'
)
AND encode(convert_to(name, 'SQL_ASCII'), 'hex') =
'e38090e888aae5a4a9e4bfa1e681afe4bfa1e8afbae7bde38091';
-- Rollback guidance: do not restore the invalid byte sequence. If rollback is
-- required, keep the repaired UTF-8 values and only roll back application code.