fix: preserve NUL characters in persisted messages

Store message text as UTF-8 bytes and migrate existing rows without loss.
Cover HTTP round trips, restart persistence, Unicode limits and idempotent retries.
Adapt direct database tools to the binary storage format.
This commit is contained in:
Самохвалов Андрей Ремович
2026-11-07 09:53:39 +03:00
parent b3dae2855f
commit 3862765327
7 changed files with 169 additions and 7 deletions
+6
View File
@@ -0,0 +1,6 @@
-- PostgreSQL text cannot contain U+0000; bytea preserves the complete UTF-8 payload.
-- API validation enforces the 4000-character limit (up to 16000 UTF-8 bytes).
ALTER TABLE messages DROP CONSTRAINT messages_text_check;
ALTER TABLE messages ALTER COLUMN text TYPE bytea USING convert_to(text, 'UTF8');
ALTER TABLE messages ADD CONSTRAINT messages_text_check
CHECK (octet_length(text) <= 16000);