supabase-schema
Supabase 声明式模式工作流程。在修改数据库架构、创建迁移或使用 PostgreSQL 类型时使用。涵盖停止-编辑-差异-启动循环。
📖 中文导读:Supabase 声明式模式工作流程。在修改数据库架构、创建迁移或使用 PostgreSQL 类型时使用。涵盖停止-编辑-差异-启动循环。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
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