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:
Pedro Rodrigues
2026-02-09 19:00:59 +00:00
parent 26b8ecb6e6
commit f50551039b
3 changed files with 28 additions and 28 deletions

View File

@@ -1,13 +1,13 @@
---
title: Use supabase db diff for Dashboard Changes
title: Use npx supabase db diff for Dashboard Changes
impact: HIGH
impactDescription: Captures manual changes into version-controlled migrations
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.
**Incorrect:**
@@ -22,10 +22,10 @@ migration files for version control.
```bash
# After making Dashboard changes, generate migration
supabase db diff -f add_profiles_table
npx supabase db diff -f add_profiles_table
# Review and test
supabase db reset
npx supabase db reset
# Commit to version control
git add supabase/migrations/
@@ -38,14 +38,14 @@ git commit -m "Add profiles table migration"
2. Generate migration from diff:
```bash
supabase db diff -f add_profiles_table
npx supabase db diff -f add_profiles_table
```
3. Review generated migration in `supabase/migrations/`
4. Test locally:
```bash
supabase db reset
npx supabase db reset
```
5. Commit migration to version control
@@ -54,21 +54,21 @@ supabase db reset
```bash
# Start local Supabase
supabase start
npx supabase start
# Make changes via Dashboard or SQL
# Generate diff
supabase db diff -f my_changes
npx supabase db diff -f my_changes
```
## Diff Against Remote Database
```bash
# 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
supabase db diff --linked -f sync_remote_changes
npx supabase db diff --linked -f sync_remote_changes
```
## What diff Captures

View File

@@ -81,7 +81,7 @@ Migrations in `supabase/migrations/` are named with timestamps:
Create new migration:
```bash
supabase migration new create_users
npx supabase migration new create_users
```
## Related

View File

@@ -8,36 +8,36 @@ tags: migrations, testing, supabase-cli, local-development
## Test Migrations with supabase db reset
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:**
```bash
# Deploying directly without testing
supabase db push # Migration fails in production!
npx supabase db push # Migration fails in production!
```
**Correct:**
```bash
# 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
supabase db push
npx supabase db push
```
## Testing Workflow
```bash
# Start local Supabase
supabase start
npx supabase start
# Reset database and run all migrations
supabase db reset
npx supabase db reset
# Verify tables and data
supabase inspect db table-sizes
npx supabase inspect db table-sizes
```
## What db reset Does
@@ -70,10 +70,10 @@ on conflict (id) do nothing;
```bash
# Apply all pending migrations
supabase migration up
npx supabase migration up
# Check migration status
supabase migration list
npx supabase migration list
```
## Repair Failed Migration
@@ -83,20 +83,20 @@ If a migration partially fails:
```bash
# Fix the migration file
# Then repair the migration history
supabase migration repair --status applied 20240315120000
npx supabase migration repair --status applied 20240315120000
```
## Inspect Database State
```bash
# View tables
supabase inspect db table-sizes
npx supabase inspect db table-sizes
# View indexes
supabase inspect db index-usage
npx supabase inspect db index-usage
# View cache hit rate
supabase inspect db cache-hit
npx supabase inspect db cache-hit
```
## CI/CD Integration
@@ -105,9 +105,9 @@ supabase inspect db cache-hit
# GitHub Actions example
- name: Test migrations
run: |
supabase start
supabase db reset
supabase test db # Run pgTAP tests
npx supabase start
npx supabase db reset
npx supabase test db # Run pgTAP tests
```
## Related