writing-migrations

Generate minimal Supabase SQL migrations from application code branch diffs.

Updated Jun 26, 2026
One-click install
npx skills add https://github.com/marmelab/atomic-crm-demo-art-teaching --skill writing-migrations-marmelab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-migrations
Source: https://github.com/marmelab/atomic-crm-demo-art-teaching/tree/main/.claude/skills/writing-migrations
Command: npx skills add https://github.com/marmelab/atomic-crm-demo-art-teaching --skill writing-migrations-marmelab

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the error-prone, manual work of writing Supabase SQL migrations when application code changes require schema updates, ensuring migrations are minimal, correct, and aligned with the actual code diff.

Core Features & Use Cases

  • Automated Schema Diffing: Computes the net schema change from a session branch diff, automatically ignoring non-schema modifications like CSS, layout, and test changes.
  • Idempotent Migration Generation: Produces guarded SQL statements that only include incremental deltas not already deployed, preventing schema drift.
  • Postgres Correctness Enforcement: Automatically applies critical rules like enabling RLS for new tables with valid policies and maintaining correct column order in database views to avoid deployment errors.
  • Use Case: When a developer adds a new priority field to the tasks entity in a CRM session, this Skill generates the correct ALTER TABLE migration and updates any dependent views to prevent Postgres ordinal shift errors.

Quick Start

Use the writing-migrations skill to generate the deploy-time SQL migration for the current session's schema changes and commit it to the simple worktree.

Frequently Asked Questions about writing-migrations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate idempotent Supabase SQL migrations from code diffs?

To generate idempotent Supabase SQL migrations, process application code branch diffs to extract schema changes, automatically filtering out non-schema modifications. This produces guarded SQL statements containing only incremental deploy-time deltas to prevent schema drift.

Why do my Postgres database views break after adding a new column in Supabase?

Postgres database views break due to column ordinal shift errors when new columns are added. Correct Supabase migrations must maintain proper view column ordering during schema synchronization to prevent deployment failures.

How to enable Row Level Security policies automatically for new Supabase tables?

To enable Row Level Security (RLS) policies for new Supabase tables, apply Postgres correctness rules during migration generation. Valid RLS policy configuration is automatically enforced for new tables to secure data access.

What is the best way to sync database schema changes with application code in Supabase?

The best way to sync database schema with application code is computing the net schema change from a session branch diff. This automated schema diffing ignores UI and test changes, ensuring minimal and correct deploy-time synchronization.

Can I generate SQL migrations that only include schema changes and ignore test updates?

Yes, you can generate SQL migrations that ignore test updates by filtering non-schema modifications from the code diff. Automated schema diffing excludes CSS, layout, and test-only changes, producing minimal incremental deployment deltas.

What are the limitations of automated schema diffing for Supabase migrations?

Automated schema diffing for Supabase migrations is limited to session-based development workflows where code changes require database schema adjustments. It filters non-schema modifications and focuses solely on deploy-time schema synchronization tasks.