| .. | ||
| src | ||
| migrator.config.ts | ||
| mydatabase.db | ||
| package.json | ||
| README.md | ||
| sqlite.db | ||
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 FROMin dependency-safe order)
Requirements
- Tables must already exist on the target database
- Schema must match the backend Drizzle schemas
Usage
Run from repo root:
- Edit the TypeScript config file:
apps/migrator/migrator.config.ts
- Run migration:
bun --cwd apps/migrator run migrate
Config fields (apps/migrator/migrator.config.ts)
from:postgresorsqliteto:postgresorsqlitesource: Postgres connection string or SQLite file pathtarget: Postgres connection string or SQLite file pathbatchSize: optional batch size (default:500)
Examples
Update `apps/migrator/migrator.config.ts` and run:
```bash
bun --cwd apps/migrator run migrate
```bash
Update `apps/migrator/migrator.config.ts` and run:
```bash
bun --cwd apps/migrator run migrate
## Notes
- IDs are copied as-is to preserve relationships.
- For Postgres targets, sequences may need manual reset after import.