Explain Drizzle migration collisions in pull requests.
English · 简体中文
Contributing · Support · Security · Maintainers
drizzle-migration-guard wraps drizzle-kit check, turns raw failures into a short diagnosis, and leaves a sticky PR comment with concrete next steps when your migration history collides.
| Capability | Raw drizzle-kit check |
drizzle-migration-guard |
|---|---|---|
| Pull request-aware execution | Manual log inspection | Automatically scopes checks to relevant PR changes |
| Collision diagnosis | Raw CLI output | Classifies failures into actionable categories |
| GitHub Actions summary | Not provided by default | Writes a readable markdown summary |
| Sticky PR comment | Not provided by default | Posts a fix-oriented PR comment |
| Monorepo targeting | Manual scripting | Supports working-directory and explicit config input |
| Blocking policy | All-or-nothing shell scripting | collision, all, or none via fail-on |
| Re-run guidance | Reviewer must infer next steps | Gives a concrete fix recipe in the PR |
Drizzle already ships drizzle-kit check, but the default output still makes reviewers jump between logs, local repro steps, and migration snapshots. This action adds the experience layer:
- Auto-detects
drizzle.config.tsin the working directory. - Skips itself when the PR does not touch Drizzle config, schema, or migration files.
- Normalizes failures into
collision/history,config/dependency, orunknown. - Writes a GitHub Actions summary and a sticky PR comment with a fix recipe.
- Blocks the PR only for
collision/historyby default.
Use the latest major tag in workflows so you automatically receive compatible patch updates.
name: drizzle-migration-guard
on:
pull_request:
paths:
- "drizzle.config.ts"
- "src/db/**"
- "drizzle/**"
- "package.json"
- "package-lock.json"
jobs:
guard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- uses: saudademjj/drizzle-migration-guard@v1
with:
github-token: ${{ github.token }}Use working-directory to choose which package should run drizzle-kit check, and use config when the config file is not the default drizzle.config.* in that directory.
name: drizzle-migration-guard-monorepo
on:
pull_request:
paths:
- "packages/api/**"
- "package.json"
- "package-lock.json"
- "pnpm-lock.yaml"
jobs:
guard-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- uses: saudademjj/drizzle-migration-guard@v1
with:
github-token: ${{ github.token }}
working-directory: packages/api
config: drizzle.config.ts| Input | Default | Notes |
|---|---|---|
config |
empty | Comma or newline separated config paths or glob patterns. Use this for multi-package repos. |
working-directory |
. |
Directory where drizzle-kit check runs. |
fail-on |
collision |
collision, all, or none. |
comment-mode |
sticky |
sticky or off. |
github-token |
empty | Used to read PR files and update the sticky comment. |
timeout-seconds |
60 |
Timeout for drizzle-kit check (seconds). |
| Output | Meaning |
|---|---|
status |
success, failure, or skipped |
summary |
One-line job summary |
report-path |
Absolute path to the generated markdown report |
- Default discovery only checks the first root-level
drizzle.config.*file it finds. - Multi-config support is explicit by design. Pass config paths through the
configinput. - The action expects
drizzle-kitto be available in the checked-out project. It callsnpx --no-install drizzle-kit check. - Non-blocking failures still appear in the step summary and comment, but only
collision/historyfails the job by default. - Package-local
package.jsonand common lockfiles are treated as relevant PR changes, so monorepo packages do not get skipped when dependencies move. - Renamed PR files are matched against both the current path and the previous path reported by GitHub.
This usually means the PR did not touch the config file, schema files, migration directory, or package manifest paths tracked for that config. In monorepos, double-check that working-directory points at the package that owns the Drizzle config.
Install drizzle-kit before the action runs, usually with npm ci, pnpm install --frozen-lockfile, or your team's equivalent. The action calls npx --no-install drizzle-kit check, so it expects the dependency to already exist in CI.
That happens when github-token is missing. Without it, the action cannot read the PR file list from GitHub, so it falls back to checking every discovered config.
This repository intentionally omits committed GitHub workflow files because GitHub Marketplace requires published action repositories to stay workflow-free.
npm install
npm run build
npm testSee CONTRIBUTING.md for contribution workflow, validation expectations, and PR guidance, CODE_OF_CONDUCT.md for community standards, and SECURITY.md for vulnerability reporting guidance. For support paths and maintainer expectations, see SUPPORT.md and MAINTAINERS.md.
MIT