supabase-migrations
Create and manage Supabase database migrations using MCP tools. Use when creating tables, modifying schemas, adding RLS policies, or working with database structure.
When & Why to Use This Skill
This Claude skill provides a comprehensive suite of MCP tools to automate Supabase database management and migrations. It solves the complexity of manual schema evolution by allowing users to create tables, modify structures, and implement Row Level Security (RLS) policies through natural language, while ensuring best practices with built-in security advisors and TypeScript type generation.
Use Cases
- Schema Evolution: Automatically generate and apply SQL migrations to add tables, columns, or indexes to a Supabase project.
- Security Implementation: Define and enable Row Level Security (RLS) policies to protect sensitive user data and ensure multi-tenant isolation.
- Type-Safe Full-Stack Development: Synchronize database changes with frontend code by generating updated TypeScript types immediately after migrations.
- Performance and Security Auditing: Use the get_advisors tool to detect missing indexes or security vulnerabilities in the current database schema.
- Migration Tracking: List and review migration history and existing table structures to maintain a clear overview of the database state across environments.
| name | supabase-migrations |
|---|---|
| description | Create 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 changesmcp__supabase__execute_sql- Run queries (not for DDL)mcp__supabase__list_tables- View existing tablesmcp__supabase__list_migrations- View migration historymcp__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.