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.
7 lines
402 B
SQL
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);
|