supabase-schema
Supabase declarative schema workflow. Use when modifying database schemas, creating migrations, or working with PostgreSQL types. Covers the stop-edit-diff-start cycle.
When & Why to Use This Skill
This Claude skill automates the Supabase declarative schema workflow, providing a structured approach to managing PostgreSQL database evolutions. It streamlines the complex 'stop-edit-diff-start' cycle, ensuring that schema changes are accurately captured in migrations and synchronized with TypeScript types, which minimizes manual errors and prevents schema drift in local development environments.
Use Cases
- Schema Modification & Migration: Safely updating database structures by automating the process of stopping the local instance, editing schema files, and generating precise SQL migrations.
- Full-Stack Type Synchronization: Automatically regenerating TypeScript types immediately after database changes to maintain end-to-end type safety across the application.
- Database Testing and Validation: Streamlining the 'reset and test' workflow to verify that new schema changes don't break existing database constraints or application logic.
- Declarative Workflow Enforcement: Ensuring all team members follow the declarative schema pattern rather than writing manual migrations, maintaining a single source of truth in the `supabase/schemas/` directory.
| name | supabase-schema |
|---|---|
| description | Supabase declarative schema workflow. Use when modifying database schemas, creating migrations, or working with PostgreSQL types. Covers the stop-edit-diff-start cycle. |
Supabase Declarative Schema
Send uses Supabase's Declarative Schema approach. Schemas are defined in supabase/schemas/ - migrations are generated from schema changes, not written manually.
Schema Change Workflow
IMPORTANT: Always stop the database before modifying schema files.
# 1. Stop database
cd supabase && yarn stop
# 2. Edit schema files in supabase/schemas/
# 3. Generate migration from changes
cd supabase && yarn migration:diff <migration_name>
# 4. Start database to apply
cd supabase && yarn start
Common Commands
# Start local Supabase
cd supabase && yarn start
# Reset database (after migration changes)
cd supabase && yarn reset
# Generate TypeScript types
cd supabase && yarn generate
# Run database tests
cd supabase && yarn test
Schema Files
Location: supabase/schemas/
Edit these files directly. The CI pipeline includes schema drift detection to ensure migrations stay in sync with declarative schemas.
After Schema Changes
- Reset database:
cd supabase && yarn reset - Regenerate types:
cd supabase && yarn generate - Run tests:
cd supabase && yarn test