Latin-1 is a legacy character encoding associated with ISO-8859-1. A MySQL database can retain latin1 tables even after the server default changes, making migrations to PostgreSQL fail when bytes are interpreted as UTF-8. section 10.3
A migration that fails on é
A dump containing the Latin-1 byte 0xe9 for é can produce PostgreSQL’s invalid UTF-8 byte-sequence error. Converting the dump to UTF-8 exposes the original encoding mismatch instead of silently correcting it. section 10.3
ERROR: invalid byte sequence for encoding "UTF8": 0xe9
Use the PostgreSQL error output to identify bytes that are invalid under UTF-8. section 10.3
Handle a Latin-1 dump as a migration artifact:
- Convert it explicitly from latin1 to UTF-8 with iconv before retrying the import. section 10.3
- Check for ASCII NUL characters after conversion; PostgreSQL cannot place code zero in a string constant. section 10.3
iconv -f latin1 -t utf8 prod_dump_latin1.sql -o prod_dump_utf8.sql
Run the supplied conversion command to rewrite a Latin-1 dump as UTF-8. section 10.3
