# Migrator Data-only migration tool between Postgres and SQLite using Drizzle. ## What it does - Copies data from source to target - Does NOT create or alter tables - Overwrites target data if any rows exist (via `DELETE FROM` in dependency-safe order) ## Requirements - Tables must already exist on the target database - Schema must match the backend Drizzle schemas ## Usage Run from repo root: ```bash bun --cwd apps/migrator run migrate --from postgres --to sqlite --source "" --target "" ``` ```bash bun --cwd apps/migrator run migrate --from sqlite --to postgres --source "" --target "" ``` ### Flags - `--from`: `postgres` or `sqlite` - `--to`: `postgres` or `sqlite` - `--source`: Postgres connection string or SQLite file path - `--target`: Postgres connection string or SQLite file path - `--batch`: optional batch size (default: `500`) ## Examples ```bash bun --cwd apps/migrator run migrate \ --from postgres \ --to sqlite \ --source "postgres://user:pass@host:5432/db" \ --target "./sqlite.db" ``` ```bash bun --cwd apps/migrator run migrate \ --from sqlite \ --to postgres \ --source "./sqlite.db" \ --target "postgres://user:pass@host:5432/db" \ --batch 1000 ``` ## Notes - IDs are copied as-is to preserve relationships. - For Postgres targets, sequences may need manual reset after import.