← All docs

Alembic

Python

Alembic migrations are Python files. Use alembic upgrade --sql to extract SQL.

Auto-Detection

MigrationPilot auto-detects Alembic via alembic.ini or the alembic/ directory.

Migration Path

Default migration file pattern:

alembic/versions/**/*.sql

Setup

# Generate SQL from an Alembic revision
alembic upgrade head --sql > /tmp/migration.sql

# Analyze the generated SQL
npx migrationpilot analyze /tmp/migration.sql

# Or pipe directly
alembic upgrade head --sql | npx migrationpilot analyze --stdin

GitHub Action

Add to your CI workflow:

- name: Check Alembic migrations
  run: |
    alembic upgrade head --sql | npx migrationpilot analyze --stdin --fail-on critical

Configuration

Add a config file to set the default migration path:

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