Skip to main content
command

supabase-migration-assistant — Claude Code command

Generates and validates Supabase database migrations. It builds SQL scripts, updates TypeScript definitions, and prepares rollback steps.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --command database/supabase-migration-assistant
Open on GitHub

What supabase-migration-assistant does

This command automates schema workflows for Supabase databases. It inspects existing migration files and uncommitted changes across .sql and .ts files, then plans table creation, schema alterations, seeding, or rollbacks based on passed flags.

Execution covers SQL file generation, integrity checks, and TypeScript type synchronization for client interfaces. The assistant applies schema updates through a Supabase MCP server. Without a configured MCP server, applying migrations directly to the database will fail.

The workflow also prepares rollback scripts and runs dry-run validations against development data. It operates using Read, Write, Edit, and Bash tools.

What it helps with

  • generate SQL migration files for table creation or alterations
  • synchronize TypeScript types with the updated database schema
  • prepare and test rollback procedures
  • validate constraints and data integrity on development data
  • create seed scripts for initial database records

Example prompts for the agent

  • /supabase-migration-assistant --create Add profiles table with id, username, and avatar_url
  • /supabase-migration-assistant --alter Add a status column to the orders table
  • /supabase-migration-assistant --rollback Prepare a rollback for the latest schema change

How to install supabase-migration-assistant

1claude-code-templates

npx claude-code-templates@latest --command database/supabase-migration-assistant

2Manually: put the files in place

.claude/commands/supabase-migration-assistant.md

Call it with /supabase-migration-assistant. For all projects use ~/.claude/commands/

Questions about supabase-migration-assistant

How to install supabase-migration-assistant in Claude Code?

Run npx claude-code-templates@latest --command database/supabase-migration-assistant or save the command file to .claude/commands/supabase-migration-assistant.md.

What does supabase-migration-assistant do?

It inspects project SQL files, generates Supabase database migrations, updates TypeScript types, and tests schema changes before applying them.

What tools and requirements does the command need?

It requires Read, Write, Edit, and Bash tool permissions in Claude Code. Applying schema changes directly to Supabase also requires an active MCP server integration.

Source text

supabase-migration-assistant.md · MIT
---
allowed-tools: Read, Write, Edit, Bash
argument-hint: "[migration-type] | --create | --alter | --seed | --rollback"
description: Generate and manage Supabase database migrations with automated testing and validation
---

# Supabase Migration Assistant

Generate and manage Supabase migrations with comprehensive testing and validation: **$ARGUMENTS**

## Current Migration Context

- Supabase project: MCP integration for migration management and validation
- Migration files: !`find . -name "*migrations*" -type d -o -name "*.sql" | head -5` existing migration structure
- Schema version: Current database schema state and migration history
- Local changes: !`git diff --name-only | grep -E "\\.sql$|\\.ts$" | head -3` pending database modifications

## Task

Execute comprehensive migration management with automated validation and testing:

**Migration Type**: Use $ARGUMENTS to specify table creation, schema alterations, data seeding, or migration rollback

**Migration Management Framework**:
1. **Migration Planning** - Analyze schema requirements, design migration strategy, identify dependencies, plan rollback procedures
2. **Code Generation** - Generate migration SQL files, create TypeScript types, implement safety checks, optimize execution order
3. **Validation Testing** - Test migration on development data, validate schema changes, verify data integrity, check constraint violations
4. **Supabase Integration** - Apply migrations via MCP server, monitor execution status, handle error conditions, validate final state
5. **Type Generation** - Generate TypeScript types, update application interfaces, sync with client-side schemas, maintain type safety
6. **Rollback Strategy** - Create rollback migrations, test rollback procedures, implement data preservation, validate recovery process

**Advanced Features**: Automated type generation, migration testing, performance impact analysis, team collaboration, CI/CD integration.

**Safety Measures**: Pre-migration backups, dry-run validation, rollback testing, data integrity checks, performance monitoring.

**Output**: Complete migration suite with SQL files, TypeScript types, test validation, rollback procedures, and deployment documentation.

© davila7 · MIT · davila7/claude-code-templates

Similar slash commands

All slash commands for Data and databases →

From the same set224

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor