Documentation
¶
Overview ¶
Command pg2sqlite migrates IAM's xorm-managed Postgres database to a SQLite file. Used during the postgres → SQLite consolidation.
Usage:
pg2sqlite -src "user=hanzo password=... host=postgres port=5432 dbname=iam sslmode=disable" \
-dst /tmp/iam-staging.db
Strategy:
- Open source Postgres engine using the same xorm dialect IAM uses.
- Sync2 every IAM model struct against a fresh SQLite file so the destination has the same schema as the running app expects.
- Iterate every table in source, read all rows as []map[string]any, and bulk-insert into the destination SQLite engine.
- Report per-table row counts so the operator can verify parity before flipping the cluster ConfigMap.
This avoids xorm.DumpAllToFile(SQLITE) round-trips through SQL text, which mis-quote bytea / control characters / DEFAULT values on cross-DB exports. The struct-driven path also guarantees schema drift is caught: any column the destination Sync2 adds (because the model has it but the source pg DB is behind on migrations) is logged.
Click to show internal directories.
Click to hide internal directories.