SchemaLens in Your CI/CD Pipeline
Step-by-step setup for GitHub Actions and GitLab CI. Catch migration risks before they merge.
Run SchemaLens in your CI/CD pipeline to automatically diff database schemas on every pull request. Get a markdown report of breaking changes, dropped columns, and missing indexes posted directly to your PR — before it reaches production.
No database connection required. Works with any SQL dump or migration file.
Pick your platform, copy the template, and start catching breaking schema changes on every pull request.
Answer 4 questions. Auto-detect schema files from public GitHub repos. Get a ready-to-commit config file. Or browse copy-paste examples.
The cheapest place to fix a migration is before it ships.
Automatically flag dropped tables, removed columns, NOT NULL without defaults, and type narrowing. Stop dangerous migrations at the PR gate.
SchemaLens posts a formatted markdown diff report as a PR comment. Reviewers see exactly what changed — tables, columns, constraints, indexes — without leaving GitHub.
A single Node.js file with no npm install required. Drop ci/schemalens-diff.js into your repo and run it in any CI platform that supports Node 18+.
PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, and Oracle. Pass --dialect=postgres (or mysql, sqlite, mssql, oracle) and get dialect-aware diff reports.
SchemaLens understands CREATE TABLE structure. It compares columns, types, defaults, constraints, indexes, triggers, and views — not just lines of text.
Export diff reports as Markdown for human review or JSON for programmatic pipeline gates. Fail the build only when breaking changes are detected.
Get notified the moment schema drift is detected — and keep a shared history for your team.
The SchemaLens hosted webhook sends rich alerts to Slack or Microsoft Teams with risk scores, breaking changes, and full migration SQL.
Every alert generates a public link like schemalens.tech/schema-drift-alert.html#.... Share it in Slack, paste it in Jira, or forward it to on-call.
Open alert links to build a local team dashboard with risk trends, breaking change history, and CSV export. No server-side data storage required.
Add this workflow to .github/workflows/schema-diff.yml to diff schemas on every SQL-related PR.
🚀 Use the Official SchemaLens GitHub Action (Free) 👁️ Live Demo
name: Schema Diff
on:
pull_request:
paths:
- 'db/schema.sql'
- 'migrations/*.sql'
- '**/*.sql'
jobs:
schema-diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run SchemaLens Diff
id: diff
run: |
git show origin/\${{ github.base_ref }}:db/schema.sql > /tmp/schema_base.sql 2>/dev/null || echo "-- No base schema" > /tmp/schema_base.sql
node ci/schemalens-diff.js /tmp/schema_base.sql db/schema.sql --dialect=postgres --format=markdown --output=/tmp/report.md
echo "report<> \$GITHUB_OUTPUT
cat /tmp/report.md >> \$GITHUB_OUTPUT
echo "EOF" >> \$GITHUB_OUTPUT
- name: Comment PR
uses: actions/github-script@v7
with:
script: |
const report = `\${{ steps.diff.outputs.report }}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## SchemaLens Diff Report\n\n' + report
});
Add this job to .gitlab-ci.yml to run schema diffs on merge requests.
schema_diff:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- db/schema.sql
- migrations/*.sql
image: node:20-alpine
script:
- git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- git show origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME:db/schema.sql > /tmp/schema_base.sql 2>/dev/null || echo "-- No base schema" > /tmp/schema_base.sql
- node ci/schemalens-diff.js /tmp/schema_base.sql db/schema.sql --dialect=postgres --format=markdown --output=schema_diff_report.md
artifacts:
paths:
- schema_diff_report.md
expire_in: 1 week
Copy bitbucket-pipelines.yml from this repo or use the template below.
image: node:20
pipelines:
pull-requests:
'**':
- step:
name: Schema Diff
script:
- git fetch origin $BITBUCKET_PR_DESTINATION_BRANCH
- git show origin/$BITBUCKET_PR_DESTINATION_BRANCH:db/schema.sql > /tmp/schema_base.sql 2>/dev/null || echo "-- No base schema" > /tmp/schema_base.sql
- node ci/schemalens-diff.js /tmp/schema_base.sql db/schema.sql --dialect=postgres --format=markdown --output=schema_diff_report.md
artifacts:
- schema_diff_report.md
Add a schema diff stage to your Jenkinsfile. Works with multibranch pipelines and freestyle jobs.
// Jenkinsfile
pipeline {
agent any
environment {
SCHEMA_PATH = 'db/schema.sql'
DIALECT = 'postgres'
FAIL_ON_BREAKING = 'true'
SKIP_NO_SQL_CHANGE = 'true'
}
stages {
stage('Schema Diff') {
steps {
sh 'curl -sL https://schemalens.tech/ci/jenkins-diff.sh | bash'
}
}
}
post {
always {
archiveArtifacts artifacts: 'schema_diff_report.md'
}
}
}
Add a schema diff job to your CircleCI workflow. Works with any GitHub-connected project.
# .circleci/config.yml
version: 2.1
jobs:
schema-diff:
docker:
- image: cimg/node:20.0
steps:
- checkout
- run:
name: Schema Diff
command: curl -sL https://schemalens.tech/ci/circleci-diff.sh | bash
- store_artifacts:
path: schema_diff_report.md
Add this job to azure-pipelines.yml to diff schemas on every SQL-related pull request.
trigger:
branches:
include:
- main
pr:
paths:
include:
- '**/*.sql'
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
fetchDepth: 0
- task: NodeTool@0
inputs:
versionSpec: "20.x"
- script: |
git fetch origin $(System.PullRequest.TargetBranch)
git show origin/$(System.PullRequest.TargetBranch):db/schema.sql > /tmp/schema_base.sql 2>/dev/null || echo "-- No base schema" > /tmp/schema_base.sql
node ci/schemalens-diff.js /tmp/schema_base.sql db/schema.sql --dialect=postgres --format=markdown --output=/tmp/report.md
cat /tmp/report.md
displayName: 'SchemaLens Schema Diff'
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
- task: PublishBuildArtifacts@1
inputs:
PathToPublish: '/tmp/report.md'
ArtifactName: 'schema-diff-report'
displayName: 'Publish diff report'
Use the same diff engine locally or in any CI platform.
# Download the CLI
curl -OL https://schemalens.tech/ci/schemalens-diff.js
# Basic usage
node ci/schemalens-diff.js old_schema.sql new_schema.sql
# With options
node ci/schemalens-diff.js old_schema.sql new_schema.sql \
--dialect=postgres \
--format=markdown \
--output=diff_report.md
# JSON output for programmatic gates
node ci/schemalens-diff.js old_schema.sql new_schema.sql \
--dialect=mysql \
--format=json \
--output=diff.json
Step-by-step setup for GitHub Actions and GitLab CI. Catch migration risks before they merge.
Learn how to catch dropped columns, missing indexes, and type changes before they cause incidents.
A practical guide to schema review workflows for teams of any size.
Block breaking schema changes before they leave a developer's machine. Works with plain git hooks or the pre-commit framework.
Pin your schema to a deterministic SHA-256 fingerprint. Generate a schema.lock file and CI verification script to catch unexpected drift.
Generate a polished GitHub PR comment from any schema diff. Includes risk score, migration SQL, rollback, and reviewer checklist.
Turn any schema diff into a manager-ready impact report. Operational risk, application impact, downtime exposure, and recommended actions.
A complete propose-review-test-deploy-verify workflow for managing schema changes safely across teams.
The free integration catches breaking changes. The Team plan adds alerts, dashboards, and shared history so nothing slips through.
$29/mo or $290/yr · one prevented incident pays for a year
👁️ Preview Team Workspace Start Team Plan — $29/mo Calculate ROIFree forever for open source. No credit card required to start. Generate manager approval email →
Running CI/CD at scale? Give your platform team a shared schema control plane with breaking-change gates, lockfile verification, and drift alerts.
Data engineering teams use SchemaLens in CI/CD to catch source schema changes before dbt models, ETL jobs, and warehouse loads fail.
Copy the workflow template, drop in the CLI script, and start catching migration risks before they hit production. Free forever for open source and small teams.
Add GitHub Action → Try SchemaLens FreeNo signup required. No data leaves your browser.