MySQL → PostgreSQL
Convert MySQL TINYINT(1) to PostgreSQL boolean
MySQL has no real boolean type — TINYINT(1) is the de-facto convention. PostgreSQL has a native boolean, so the correct migration turns 0/1 into false/true.
TINYINT(1) → boolean
What to know
- TINYINT(1) → boolean; other TINYINT widths → smallint
- Values 0 → false, 1 (and any non-zero) → true
- Defaults like DEFAULT '0' become DEFAULT false
- If a TINYINT(1) column actually stores small numbers (not flags), cast it back to smallint after import
Before / after
MySQL
CREATE TABLE users (
is_admin TINYINT(1) NOT NULL DEFAULT 0
); PostgreSQL
CREATE TABLE users (
is_admin boolean NOT NULL DEFAULT false
); Don't convert column-by-column — convert the whole database.
Upload a dump, get back ready-to-import SQL with this mapping (and every other one) applied.
Open the MySQL → PostgreSQL converterSee the full type mapping table or all guides.