schema_migrator

Merge SQL migration fragments into a unified RLS-protected schema.

Updated Feb 26, 2026
One-click install
npx skills add https://github.com/haulcommand-max/haul-command --skill schema-migrator-haulcommand-max
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: schema_migrator
Source: https://github.com/haulcommand-max/haul-command/tree/main/skills/schema_migrator
Command: npx skills add https://github.com/haulcommand-max/haul-command --skill schema-migrator-haulcommand-max

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Consolidates divergent SQL schema fragments into a single, unified, RLS-protected source of truth.

Core Features & Use Cases

  • Read the Master: Read supabase/unified_schema.sql (The Master).
  • Read all files in supabase/migrations/.
  • Identify New Tables, New Columns (ALTER), New Types (ENUM), New RLS Policies.
  • Consolidation Phase: Do NOT delete migration files; Update unified_schema.sql to include the new logic in the correct "Layer" order:
    1. Extensions/Types
    2. Spine Tables (Identity, Jurisdictions)
    3. Feature Tables (Leads, Offers)
    4. Logic Tables (Rules, Rates)
    5. Logs/Analytics
    6. RLS Policies
  • RLS Enforcement: Every new table MUST have:
    • ALTER TABLE x ENABLE ROW LEVEL SECURITY;
    • A "Service Role" Policy (Full Access).
    • A "User" Policy (Select/Insert own data).
  • Output: Write the updated unified_schema.sql and output a "Schema Changelog" summary.

Quick Start

Use the schema migrator to merge new migrations into the master unified_schema.sql following the Layer order.

Frequently Asked Questions about schema_migrator

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

FAQPage Schema
How do I consolidate multiple Postgres migration files into one unified schema?

To consolidate Postgres migrations, this skill reads your master unified_schema.sql file and merges new migration fragments into a single source of truth ordered by extensions, tables, and RLS policies, preserving original files.

What is the correct layer order for merging new SQL schema tables and columns?

The correct layer order for schema merging groups database objects sequentially: Extensions and Types, Spine Tables, Feature Tables, Logic Tables, Logs and Analytics, and finally RLS Policies.

Does every new Postgres table require Row Level Security policies during schema consolidation?

Yes, RLS enforcement during schema consolidation requires every new table to enable Row Level Security, include a Service Role policy for full access, and a User policy for selecting and inserting own data.

How do I generate a schema changelog after merging new database migrations?

To generate a schema changelog after merging migrations, the consolidation process updates the unified_schema.sql master file and automatically outputs a summary detailing new tables, columns, types, and RLS policies.

Will consolidating divergent SQL schema fragments delete my original migration files?

No, consolidating divergent SQL schema fragments does not delete original migration files; it reads them to identify new tables and columns, then updates the master unified_schema.sql while leaving individual migration files intact.

When should I perform a schema audit and consolidation on my supabase migrations?

You should perform a schema audit and consolidation when your supabase/migrations directory contains multiple new SQL files that need to be merged into a unified, RLS-protected source of truth.