writing-migrations

Generate idempotent Supabase SQL migrations from session branch code diffs.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/yaresimeonthomas/-kate-crm --skill writing-migrations-yaresimeonthomas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-migrations
Source: https://github.com/yaresimeonthomas/-kate-crm/tree/main/.claude/skills/writing-migrations
Command: npx skills add https://github.com/yaresimeonthomas/-kate-crm --skill writing-migrations-yaresimeonthomas

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill eliminates the manual effort and risk of error when creating Supabase SQL migrations that match application code changes, preventing schema drift and deployment failures.

Core Features & Use Cases

  • Automated Migration Generation: Translates session branch code diffs into minimal, idempotent SQL migrations for Supabase deployment.
  • Incremental Delta Calculation: Only emits schema changes not already present in existing migrations, avoiding redundant deployments.
  • View Consistency Enforcement: Automatically recreates affected views with correct column ordering to prevent PostgreSQL ordinal shift errors. Use case: When a developer adds a new custom field to a contact entity in a CRM session, this skill generates the correct SQL migration to add that column to the database and update related summary views without breaking existing functionality.

Quick Start

Request the deploy-time migration generation for your current session branch to automatically create and commit the correct idempotent Supabase SQL migration file.

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 SQL migrations for Supabase from code diffs?

You can generate idempotent Supabase SQL migrations from code diffs by translating session branch changes into incremental database schema changes, ensuring guarded statements and preventing redundant deployments of already-applied schema updates.

What is the best way to prevent schema drift when deploying Supabase database changes?

Preventing schema drift during Supabase database changes requires calculating incremental deltas against existing migrations, emitting only the schema changes not already present to avoid deployment failures and manual SQL authoring errors.

Why do my Supabase view recreations fail with PostgreSQL ordinal shift errors?

Supabase view recreations fail with ordinal shift errors when column ordering changes are not handled correctly, requiring automated view consistency enforcement to recreate affected views and maintain correct column ordering.

Can I automatically add Row Level Security policies when creating new Supabase tables?

Yes, you can automatically add Row Level Security policies for new tables by generating guarded migration statements that align application code changes with the required RLS policies during deployment.

How do I avoid deploying redundant SQL migrations that have already been applied to Supabase?

You avoid deploying redundant SQL migrations by performing incremental delta calculation against existing migration files, ensuring only schema changes not already present in the database are emitted and applied.

Does this automated migration approach work for adding custom fields to existing database tables?

Yes, this automated migration approach works for adding custom fields by reading the code diff for your new entity field and generating the correct SQL migration to add the column and update related summary views.