HomeBack to recipes
RecipesDevOpsAuto DB Migrations on Push

TL;DR

Auto DB Migrations on Push is a devops workflow that chains Supabase + GitHub to automate a common task. Every push to main triggers a Supabase migration automatically. Schema diffs are committed and applied with zero manual steps. Once configured, it saves ~5 hours/week per backend engineer, plus elimination of 1-2 migration incidents per quarter and runs through Claude Code, Cursor, Windsurf or any MCP-compatible AI agent.

🟢🐙
DevOpsIntermediate

Auto DB Migrations on Push

Every push to main triggers a Supabase migration automatically. Schema diffs are committed and applied with zero manual steps.

10 min setup, then fully automated2 MCPs requiredSaves ~5 hours/week per backend engineer, plus elimination of 1-2 migration incidents per quarter

How it works

🟢Supabase
🐙GitHub
Automated
1GitHub webhook fires on push to main2Extract changed SQL files from diff3Run migration via Supabase MCP+2 more steps
Hostable — runs in your browser2/2 MCPs hosted

Run with MCPizy

New

Execute this recipe in your browser — no local install, no Claude Code. Streams results live.

Whitelisted MCPs: perplexity, notion, anthropic, openai, tavily, firecrawl, coingecko, stripe, slack, github, gitlab, linear, resend, sendgrid, elevenlabs, shopify, sentry, posthog, supabase-mcp, context7, deepwiki~4k tokens  ·  ~$0.012 est.

Why this combo?

Supabase handles your database schema and GitHub tracks your code changes. Together, they eliminate the manual step of applying migrations — every push with SQL changes triggers automatic schema updates on staging. This closes the gap between code and schema that causes the most deployment-day incidents.

Without this workflow

SSH into server, run migration script manually, hope nothing breaks, verify schema by hand, document the change in a spreadsheet.

With MCPizy

Push code. Migrations apply automatically. Status posted as a PR comment. Zero manual steps.

Business value

Concrete ROI — not marketing fluff.

Time saved

~5 hours/week per backend engineer, plus elimination of 1-2 migration incidents per quarter

  • Eliminates 90% of migration-day production incidents by enforcing review + auto-apply workflow
  • Cuts deployment friction — engineers stop context-switching to run migration scripts manually
  • Auditable trail: every schema change tied to a PR + commit SHA for SOC2/compliance reviews
  • Makes onboarding new engineers 3x faster — no tribal knowledge about how migrations are applied

Workflow steps

  1. 1
    GitHub webhook fires on push to main
  2. 2
    Extract changed SQL files from diff
  3. 3
    Run migration via Supabase MCP
  4. 4
    Commit migration receipt back to repo
  5. 5
    Post migration summary as PR comment

Use cases

  • Auto-apply schema changes on every PR merge to main
  • Rollback migrations automatically when PRs are reverted
  • Preview database schema diffs in PR comments before merging
  • Keep staging and production schemas always in sync

MCPs required

🟢

Supabase

Supabase MCP Server

View
🐙

GitHub

GitHub MCP Server

View

Agent prompt (copy into Claude Code)

This prompt is the workflow. Paste into Claude Code, Cursor, or Windsurf.

You are a database migration agent. Every push to main triggers this workflow.

On GitHub push event to main:
1. Call github.list_pull_requests to find the merged PR and get the commit diff
2. Filter changed files for any matching supabase/migrations/*.sql
3. For each new migration file, call supabase.apply_migration(name, query) with the file contents
4. If apply_migration returns an error, call github.create_issue with title "Migration failed: <file>" and the error body
5. On success, call github.add_pr_comment with a summary table: file | status | duration

Reply only with the migration receipt: "Applied N migrations — SHA <commit>".

Trigger & credentials

How this workflow fires and what env vars you need.

.env.example
WebhookTrigger
POST /webhook/github (add in GitHub repo → Settings → Webhooks, event: push to main)
🟢Supabase· 2 vars
SUPABASE_ACCESS_TOKENGet key

Personal access token for Supabase Management API

e.g. sbp_...

SUPABASE_PROJECT_REFGet key

Your project reference (found in project URL)

e.g. abcdefghijklmnop

🐙GitHub· 2 vars
GITHUB_TOKENGet key

Personal access token with repo + webhook scopes

e.g. ghp_...

GITHUB_WEBHOOK_SECRET

Webhook signing secret (set when creating webhook)

e.g. a-long-random-string

One-command deploy

Install everything — MCPs, prompt, env template — in a single call.

$ mcpizy recipe install supabase-github-db-migrations

✓ Installs all 2 MCP servers
✓ Writes prompt to ~/.mcpizy/prompts/supabase-github-db-migrations.md
✓ Generates .env.example in current directory
✓ Ready to paste into Claude Code

Requires mcpizy CLI v1.1+ — install via npm i -g mcpizy.

Quick install (MCPs only)

10 min setup, then fully automated
$ mcpizy install supabase && mcpizy install github

More DevOps recipes

🐙▲

Preview Deploy on Every PR

Open a PR and a Vercel preview URL appears as a comment within minutes. Branches are cleaned up automatically when PRs close.

🐳☁️

Container Deployment to AWS

Build, tag, push to ECR and deploy to ECS in one automated pipeline triggered by a git tag or manual dispatch.

⚡🐙

Branch-per-PR Databases

Each PR gets its own Neon database branch for isolated testing. Branch is deleted automatically when the PR closes.

🐙📐

Issue → Branch → PR Pipeline

A Linear issue assigned to a developer automatically creates a git branch, syncs status changes, and opens a draft PR.

Frequently asked questions

What is this workflow?

Auto DB Migrations on Push is a devops automation that uses Supabase + GitHub together via the Model Context Protocol. Every push to main triggers a Supabase migration automatically. Schema diffs are committed and applied with zero manual steps.

How long does setup take?

Setup takes around 10 min setup, then fully automated. You install the required MCP servers with `mcpizy install supabase && mcpizy install github`, connect your accounts, and the workflow is ready to run.

How much time does this workflow save?

Once running, this workflow saves ~5 hours/week per backend engineer, plus elimination of 1-2 migration incidents per quarter. The concrete business value: Eliminates 90% of migration-day production incidents by enforcing review + auto-apply workflow; Cuts deployment friction — engineers stop context-switching to run migration scripts manually.

Which MCP servers do I need for this?

You need 2 MCP servers: Supabase (mcpizy install supabase), GitHub (mcpizy install github). All are installable in one command via the MCPizy CLI and configured in your `.claude.json` or `.cursor/mcp.json`.

Does this work with Claude Code, Cursor, and Windsurf?

Yes. The workflow runs with any MCP-compatible AI agent — Claude Code, Claude Desktop, Cursor, Windsurf, VS Code with Copilot, and custom agents built on the MCP SDK. The MCP servers are identical across clients; only the config file path (`.claude.json` vs `.cursor/mcp.json`) changes.

Start building this workflow

Install the required MCPs from the marketplace and automate this in 10 min setup.

$ mcpizy install supabase && mcpizy install github

🟢Install Supabase🐙Install GitHub

Free to install. Connect your accounts and this workflow runs itself.