Database migration toolkit for Supabase projects. Use when: (1) Creating new migration files, (2) Writing schema changes (CREATE TABLE, ALTER, etc.), (3) Adding indexes, triggers, or RLS policies, (4) Fixing RLS performance issues (auth function wrapping, policy consolidation), (5) Validating migration conventions, (6) Running migrations locally, (7) Naming database objects
View on GitHubskills/supabase-migration/SKILL.md
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/ninyawee/armed-claude/blob/main/skills/supabase-migration/SKILL.md -a claude-code --skill supabase-migrationInstallation paths:
.claude/skills/supabase-migration/# Supabase Database Migrations
Toolkit for creating and managing Supabase database migrations.
**Helper Scripts Available** (uv scripts - no install needed):
- `scripts/new_migration.py` - Create migration file with proper naming
- `scripts/lint_migration.py` - Validate migration against conventions
```bash
uv run scripts/new_migration.py --help
uv run scripts/lint_migration.py --help
```
## Naming Conventions
### Object Prefixes (REQUIRED)
| Object Type | Prefix | Example |
|-------------|--------|---------|
| Tables | `tb_` | `tb_users` |
| Views | `v_` | `v_active_users` |
| Materialized Views | `mv_` | `mv_daily_stats` |
| Functions | `fn_` | `fn_get_balance_v1` |
| Triggers | `tgr_` | `tgr_update_ts` |
| Indexes | `idx_` | `idx_email` |
| Foreign Keys | `fk_` | `fk_order_user` |
| Primary Keys | `pk_` | `pk_users` |
| Unique Constraints | `uq_` | `uq_email` |
| Enum Types | `en_` | `en_status` |
| RLS Policies | `pc_` | `pc_users_select` |
**Functions MUST be versioned:** `fn_calculate_total_v1`, `fn_calculate_total_v2`
### Field Suffixes
| Suffix | Type | Example |
|--------|------|---------|
| `_dt` | date | `birth_dt` |
| `_ts` | timestamp | `login_ts` |
| `_num` | number | `items_num` |
| `_amt` | decimal | `total_amt` |
| `_pct` | decimal | `discount_pct` |
| `_uid` | uuid | `user_uid` |
| `_cd` | text | `status_cd` |
| `_bool` | boolean | `active_bool` |
| `_pn` | text | `contact_pn` |
| `_em` | text | `contact_em` |
| `_txt` | text | `description_txt` |
| `_kg` | decimal | `weight_kg` |
| `_path` | text | `avatar_path` |
**No suffix:** `id`, `name`, `email`, `created_at`, `updated_at`, `deleted_at`
### Rules
- MUST use `lowercase_snake_case`
- Tables MUST use plural forms (`tb_users` not `tb_user`)
## Decision Tree
```
Task → What type of change?
├─ New table → uv run scripts/new_migration.py "add_users_table"
├─ Alter table → uv run scripts/new_migration.py "add_avatar_to_users" --type alter
├─ New function → uv run scripts/new