supabase-migrations

jonit-dev's avatarfrom jonit-dev

Create and manage Supabase database migrations using MCP tools. Use when creating tables, modifying schemas, adding RLS policies, or working with database structure.

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 26, 2025

When & Why to Use This Skill

This Claude skill provides a comprehensive suite of MCP tools for managing Supabase database migrations and schema evolution. It streamlines the process of creating tables, modifying database structures, and implementing Row Level Security (RLS) policies directly through the AI agent. By integrating security advisors and TypeScript type generation, it ensures that database changes are not only efficient but also secure and perfectly synchronized with your application's codebase.

Use Cases

  • Automated Schema Evolution: Quickly generate and apply DDL changes for new features, such as creating user profiles or product catalogs with proper foreign key relationships.
  • Security & RLS Implementation: Use the built-in security advisor to identify missing Row Level Security policies and automatically generate SQL to restrict data access based on user IDs.
  • Full-Stack Type Safety: Automatically update TypeScript definitions after database migrations to ensure your frontend code remains in sync with the backend schema.
  • Database Auditing and Maintenance: List existing tables, review migration history, and run performance checks to maintain a healthy and optimized Supabase environment.
namesupabase-migrations
descriptionCreate and manage Supabase database migrations using MCP tools. Use when creating tables, modifying schemas, adding RLS policies, or working with database structure.

Supabase Migrations

MCP Tools Available

  • mcp__supabase__apply_migration - Apply DDL changes
  • mcp__supabase__execute_sql - Run queries (not for DDL)
  • mcp__supabase__list_tables - View existing tables
  • mcp__supabase__list_migrations - View migration history
  • mcp__supabase__get_advisors - Check for security/performance issues

Project ID

Use mcp__supabase__list_projects to find the project ID first.

Migration Naming

Use snake_case: create_users_table, add_credits_column, enable_rls_on_images

Standard Patterns

Create Table with RLS

CREATE TABLE public.images (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
  url TEXT NOT NULL,
  created_at TIMESTAMPTZ DEFAULT now()
);

ALTER TABLE public.images ENABLE ROW LEVEL SECURITY;

CREATE POLICY "Users can view own images"
  ON public.images FOR SELECT
  USING (auth.uid() = user_id);

CREATE POLICY "Users can insert own images"
  ON public.images FOR INSERT
  WITH CHECK (auth.uid() = user_id);

Add Column

ALTER TABLE public.users
ADD COLUMN credits INTEGER DEFAULT 0 NOT NULL;

Create Index

CREATE INDEX idx_images_user_id ON public.images(user_id);

Post-Migration

Always run mcp__supabase__get_advisors with type "security" after DDL changes to catch missing RLS policies.

TypeScript Types

After schema changes, use mcp__supabase__generate_typescript_types to update types.