Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CI/CD Integration

GitHub Actions

Use the official GitHub Action:

name: Check Migrations
on: [pull_request]

jobs:
  check-migrations:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: ayarotsky/diesel-guard-action@v1
        with:
          path: migrations/

This will:

  • Install diesel-guard
  • Check your migrations for unsafe patterns
  • Display detailed violation reports in workflow logs
  • Fail the workflow if violations are detected

Inputs:

InputDescriptionDefault
pathPath to migrations directory or a single .sql filemigrations/
versiondiesel-guard binary version to install (e.g. 0.9.0)latest

Pin the diesel-guard binary version (recommended for reproducible builds):

- uses: ayarotsky/diesel-guard-action@v1
  with:
    version: '0.10.0'

Option 2: Manual Installation

For more control or custom workflows:

name: Check Migrations
on: [pull_request]

jobs:
  check-migrations:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Rust toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable

      - name: Install diesel-guard
        run: cargo install diesel-guard

      - name: Check DB migrations
        run: diesel-guard check