Add fix_pikapods_dump.py to the repo; cross-reference it from the migration script

extras/fix_pikapods_dump.py patches two confirmed Adminer PostgreSQL-export
bugs that otherwise make a PikaPods Mattermost migration fail outright:
unquoted enum-label DEFAULT values (Postgres reads the bare label as a
column reference and rejects the CREATE TABLE) and boolean columns
serialized as bare 0/1 instead of true/false (Postgres doesn't implicitly
cast integers to boolean). Boolean columns are discovered by actually
parsing each CREATE TABLE in the dump rather than working from a
hand-curated list — Postgres only reports the first bad column per failed
row, so a list built from error output alone would likely be incomplete.
Already verified earlier this session against a real local Postgres 16
instance; reviewed now for anything needing redaction before committing —
it's a generic text-processing tool with no hostnames, credentials, file
paths, or personal data in it, so nothing needed changing.

Cross-referenced from the generated migrate-from-pikapods.sh's header
comment (services/mattermost.sh) so anyone hitting a CREATE TYPE/CREATE
TABLE or boolean-column import error is pointed at the fix instead of
having to rediscover it.
This commit is contained in:
Claude
2026-08-15 03:09:57 +00:00
parent a7d3dc5b5d
commit 29db2da5fc
2 changed files with 311 additions and 0 deletions
+9
View File
@@ -781,6 +781,15 @@ MD
# default). If you have a custom-format pg_dump instead, use `pg_restore`
# in place of the `psql < dump` step below.
#
# Adminer's plain-text export has two confirmed bugs of its own — unquoted
# enum-label DEFAULTs, and boolean columns serialized as bare 0/1 instead
# of true/false — either of which makes the import below fail outright.
# extras/fix_pikapods_dump.py patches both; run it on the dump BEFORE this
# script if psql reports errors on CREATE TYPE/CREATE TABLE or boolean
# columns:
# python3 fix_pikapods_dump.py input.sql output.sql
#
# IMPORTANT: point the files argument at the SUBDIRECTORY that holds
# Mattermost's own file storage inside whatever you downloaded via SFTP
# (commonly named `data`), not the whole SFTP root — PikaPods' exact