Knex
@branchly/migrator-knex drives Knex migrations: it fingerprints your migration files, applies them with knex migrate:latest, and runs your seed command on fresh databases.
Configuration
Section titled “Configuration”migrator: { use: 'knex',}| Option | Default | Meaning |
|---|---|---|
migrationsDir | 'migrations' | Where your migration files live (.js, .cjs, .mjs, .ts, .cts, .mts). |
seed | (none) | Seed command (e.g. 'npx knex seed:run'). Skipped when unset. |
applyCommand | 'npx knex migrate:latest' | The command used to apply pending migrations. |
urlEnv | 'DATABASE_URL' | The env var the apply/seed commands receive the connection under. |
Behavior
Section titled “Behavior”- Fingerprint — a hash of the migration file names in
migrationsDir. Branches with identical migration sets share snapshots. - Apply —
knex migrate:latestruns only pending migrations, satisfying the kernel’s idempotency requirement. Yourknexfileshould read its connection fromurlEnv(the commonprocess.env.DATABASE_URLpattern). - Seed — your configured command (typically
npx knex seed:run), run with the branch connection injected asurlEnv, on freshly built databases only.
branchly init recognizes every knexfile flavor — .js, .cjs, .mjs, .ts, .cts, .mts — for both migrator and datasource detection. Works with any of the datasource adapters.