Full answer
Checklist:
- Types: SQLite accepts '12abc' in an INTEGER column; PostgreSQL rejects it. Scan columns with
typeof()before migrating. - Dates: SQLite stores text or numbers; convert to
date,timestamportimestamptz, deciding the zone. - Booleans: 0 and 1 become
boolean;SUM(flag)no longer works directly. - Keys:
INTEGER PRIMARY KEYbecomesbigint GENERATED ALWAYS AS IDENTITY; reset sequences after copying data. - Strings:
LIKEis case-insensitive for ASCII in SQLite but case-sensitive in PostgreSQL (useILIKE);||with NULL gives NULL in both. - Functions:
strftimetoto_charordate_trunc,ifnulltocoalesce,group_concattostring_agg,instrtostrpos. - Grouping: bare columns in GROUP BY queries are errors in PostgreSQL.
- Division: integer division behaves the same, but division by zero errors in PostgreSQL instead of returning NULL.
- Concurrency: PostgreSQL allows many writers, so code that relied on SQLite's single writer may need explicit locking.
Many of these differences are demonstrated by runs elsewhere in this bank; the checklist itself is guidance, not a run.
Key points
- Strict types reject bad data
- Convert dates to native types
- Rename SQLite-only functions
- Bare GROUP BY columns fail in PostgreSQL
- Division by zero and LIKE case differ
Common mistakes
- Assuming identical results because queries parse
- Copying data without fixing sequences
Follow-ups
- How would you verify the migrated data?
- How would you run both databases during a transition?
Tips
- Group the checklist by category