pg2sqlite

command
v1.19.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

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:

  1. Open source Postgres engine using the same xorm dialect IAM uses.
  2. Sync2 every IAM model struct against a fresh SQLite file so the destination has the same schema as the running app expects.
  3. Iterate every table in source, read all rows as []map[string]any, and bulk-insert into the destination SQLite engine.
  4. 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL