← All docs

Knex.js

JavaScript

Knex.js uses JavaScript migration files. Write raw SQL migrations for best results.

Auto-Detection

MigrationPilot auto-detects Knex via knexfile.js or the migrations/ directory.

Migration Path

Default migration file pattern:

migrations/**/*.sql

Setup

# If using raw SQL migrations
npx migrationpilot check ./migrations

# For JS migrations, extract the SQL manually or use --stdin
# Knex doesn't have a built-in SQL preview command

GitHub Action

Add to your CI workflow:

- uses: mickelsamuel/migrationpilot@v1
  with:
    path: migrations/
    pattern: "*.sql"

Configuration

Add a config file to set the default migration path:

# .migrationpilotrc.yml
migrationPath: "migrations/**/*.sql"
failOn: critical