Files
mtusi2026lab2/migrations/009_message_text_utf8.sql
T
Самохвалов Андрей Ремович 3862765327 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.
2026-11-07 09:53:39 +03:00

7 lines
402 B
SQL

-- 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);