mirror of
https://github.com/supabase/agent-skills.git
synced 2026-03-27 10:09:26 +08:00
fix: add npx prefix to supabase CLI commands in db migration references
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
title: Use supabase db diff for Dashboard Changes
|
title: Use npx supabase db diff for Dashboard Changes
|
||||||
impact: HIGH
|
impact: HIGH
|
||||||
impactDescription: Captures manual changes into version-controlled migrations
|
impactDescription: Captures manual changes into version-controlled migrations
|
||||||
tags: migrations, supabase-cli, db-diff, dashboard
|
tags: migrations, supabase-cli, db-diff, dashboard
|
||||||
---
|
---
|
||||||
|
|
||||||
## Use supabase db diff for Dashboard Changes
|
## Use npx supabase db diff for Dashboard Changes
|
||||||
|
|
||||||
When making schema changes via Dashboard, use `supabase db diff` to generate
|
When making schema changes via Dashboard, use `npx supabase db diff` to generate
|
||||||
migration files for version control.
|
migration files for version control.
|
||||||
|
|
||||||
**Incorrect:**
|
**Incorrect:**
|
||||||
@@ -22,10 +22,10 @@ migration files for version control.
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# After making Dashboard changes, generate migration
|
# After making Dashboard changes, generate migration
|
||||||
supabase db diff -f add_profiles_table
|
npx supabase db diff -f add_profiles_table
|
||||||
|
|
||||||
# Review and test
|
# Review and test
|
||||||
supabase db reset
|
npx supabase db reset
|
||||||
|
|
||||||
# Commit to version control
|
# Commit to version control
|
||||||
git add supabase/migrations/
|
git add supabase/migrations/
|
||||||
@@ -38,14 +38,14 @@ git commit -m "Add profiles table migration"
|
|||||||
2. Generate migration from diff:
|
2. Generate migration from diff:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
supabase db diff -f add_profiles_table
|
npx supabase db diff -f add_profiles_table
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Review generated migration in `supabase/migrations/`
|
3. Review generated migration in `supabase/migrations/`
|
||||||
4. Test locally:
|
4. Test locally:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
supabase db reset
|
npx supabase db reset
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Commit migration to version control
|
5. Commit migration to version control
|
||||||
@@ -54,21 +54,21 @@ supabase db reset
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Start local Supabase
|
# Start local Supabase
|
||||||
supabase start
|
npx supabase start
|
||||||
|
|
||||||
# Make changes via Dashboard or SQL
|
# Make changes via Dashboard or SQL
|
||||||
# Generate diff
|
# Generate diff
|
||||||
supabase db diff -f my_changes
|
npx supabase db diff -f my_changes
|
||||||
```
|
```
|
||||||
|
|
||||||
## Diff Against Remote Database
|
## Diff Against Remote Database
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Link to remote project
|
# Link to remote project
|
||||||
supabase link --project-ref your-project-ref
|
npx supabase link --project-ref your-project-ref
|
||||||
|
|
||||||
# Pull remote schema and generate diff
|
# Pull remote schema and generate diff
|
||||||
supabase db diff --linked -f sync_remote_changes
|
npx supabase db diff --linked -f sync_remote_changes
|
||||||
```
|
```
|
||||||
|
|
||||||
## What diff Captures
|
## What diff Captures
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ Migrations in `supabase/migrations/` are named with timestamps:
|
|||||||
Create new migration:
|
Create new migration:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
supabase migration new create_users
|
npx supabase migration new create_users
|
||||||
```
|
```
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|||||||
@@ -8,36 +8,36 @@ tags: migrations, testing, supabase-cli, local-development
|
|||||||
## Test Migrations with supabase db reset
|
## Test Migrations with supabase db reset
|
||||||
|
|
||||||
Always test migrations locally before deploying to production. Use
|
Always test migrations locally before deploying to production. Use
|
||||||
`supabase db reset` to verify migrations run cleanly from scratch.
|
`npx supabase db reset` to verify migrations run cleanly from scratch.
|
||||||
|
|
||||||
**Incorrect:**
|
**Incorrect:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Deploying directly without testing
|
# Deploying directly without testing
|
||||||
supabase db push # Migration fails in production!
|
npx supabase db push # Migration fails in production!
|
||||||
```
|
```
|
||||||
|
|
||||||
**Correct:**
|
**Correct:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Test migrations locally first
|
# Test migrations locally first
|
||||||
supabase db reset # Runs all migrations from scratch
|
npx supabase db reset # Runs all migrations from scratch
|
||||||
|
|
||||||
# Verify success, then deploy
|
# Verify success, then deploy
|
||||||
supabase db push
|
npx supabase db push
|
||||||
```
|
```
|
||||||
|
|
||||||
## Testing Workflow
|
## Testing Workflow
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Start local Supabase
|
# Start local Supabase
|
||||||
supabase start
|
npx supabase start
|
||||||
|
|
||||||
# Reset database and run all migrations
|
# Reset database and run all migrations
|
||||||
supabase db reset
|
npx supabase db reset
|
||||||
|
|
||||||
# Verify tables and data
|
# Verify tables and data
|
||||||
supabase inspect db table-sizes
|
npx supabase inspect db table-sizes
|
||||||
```
|
```
|
||||||
|
|
||||||
## What db reset Does
|
## What db reset Does
|
||||||
@@ -70,10 +70,10 @@ on conflict (id) do nothing;
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Apply all pending migrations
|
# Apply all pending migrations
|
||||||
supabase migration up
|
npx supabase migration up
|
||||||
|
|
||||||
# Check migration status
|
# Check migration status
|
||||||
supabase migration list
|
npx supabase migration list
|
||||||
```
|
```
|
||||||
|
|
||||||
## Repair Failed Migration
|
## Repair Failed Migration
|
||||||
@@ -83,20 +83,20 @@ If a migration partially fails:
|
|||||||
```bash
|
```bash
|
||||||
# Fix the migration file
|
# Fix the migration file
|
||||||
# Then repair the migration history
|
# Then repair the migration history
|
||||||
supabase migration repair --status applied 20240315120000
|
npx supabase migration repair --status applied 20240315120000
|
||||||
```
|
```
|
||||||
|
|
||||||
## Inspect Database State
|
## Inspect Database State
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# View tables
|
# View tables
|
||||||
supabase inspect db table-sizes
|
npx supabase inspect db table-sizes
|
||||||
|
|
||||||
# View indexes
|
# View indexes
|
||||||
supabase inspect db index-usage
|
npx supabase inspect db index-usage
|
||||||
|
|
||||||
# View cache hit rate
|
# View cache hit rate
|
||||||
supabase inspect db cache-hit
|
npx supabase inspect db cache-hit
|
||||||
```
|
```
|
||||||
|
|
||||||
## CI/CD Integration
|
## CI/CD Integration
|
||||||
@@ -105,9 +105,9 @@ supabase inspect db cache-hit
|
|||||||
# GitHub Actions example
|
# GitHub Actions example
|
||||||
- name: Test migrations
|
- name: Test migrations
|
||||||
run: |
|
run: |
|
||||||
supabase start
|
npx supabase start
|
||||||
supabase db reset
|
npx supabase db reset
|
||||||
supabase test db # Run pgTAP tests
|
npx supabase test db # Run pgTAP tests
|
||||||
```
|
```
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|||||||
Reference in New Issue
Block a user