Skip to content

feat(migrations): assert UTF8 database encoding at install - #68

Merged
wolfy-j merged 1 commit into
masterfrom
feat/encoding-guard-migration
Aug 8, 2026
Merged

feat(migrations): assert UTF8 database encoding at install#68
wolfy-j merged 1 commit into
masterfrom
feat/encoding-guard-migration

Conversation

@wolfy-j

@wolfy-j wolfy-j commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Observed in production: a SQL_ASCII-encoded database accepted an install and then rejected every non-ASCII byte at write time — one poisoned commit batch at a time, long after day one (pq: conversion between UTF8 and SQL_ASCII is not supported).

A migration cannot re-encode a database, but it can refuse one: the new first migration (timestamp before 01) asserts pg_encoding = UTF8 on Postgres and fails with the fix spelled out. SQLite stores byte sequences verbatim and is not asserted.

Tests: 968 sqlite green; the postgres CI matrix runs the guard against a UTF8 database.

A Postgres database that is not UTF8 rejects every non-ASCII byte at
write time, poisoning commit batches long after install. The first
migration now asserts the contract and refuses a misprovisioned
database with the reason spelled out.
@wolfy-j
wolfy-j merged commit cc2a51f into master Aug 8, 2026
8 checks passed
@wolfy-j
wolfy-j deleted the feat/encoding-guard-migration branch August 8, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant