The nself db command covers the full database lifecycle: migrations, seed data, backup/restore, interactive shell, RLS auditing, PITR, PgBouncer, audit trails, soft-delete scaffolding, FK index auditing, and test fixtures.
Source of truth: SPORT F02-COMMAND-INVENTORY.md — 50+ subcommand Use: strings verified from cli/cmd/commands/db*.go.
mock · types · inspect · optimize · schema scaffold · query · dataThese do not exist in the codebase. Type generation is nself generate. Use nself db shell for ad-hoc SQL queries.
nself db <subcommand> [args]| Command | Description |
|---|---|
migrate | Run, create, and manage database migrations |
seed | Manage and run seed data |
backup [file] | Create a database backup |
restore <file> | Restore from a backup file |
shell | Interactive PostgreSQL shell (psql) |
drop | Drop the database (with confirmation) |
reset | Drop and recreate the database |
list | List databases in the instance |
hasura | Hasura metadata and console operations |
rls | Row-Level Security audit and apply |
pitr | Point-in-Time Recovery management |
pgbouncer | PgBouncer connection pool management |
audit | Idempotency and schema drift audit |
soft-delete | Scaffold soft-delete patterns for tables |
fk-index | Audit and apply missing FK indexes |
fixtures | Manage deterministic test fixtures |
Run, create, and manage database migrations.
nself db migrate up # Apply all pending migrations
nself db migrate down # Roll back the last migration
nself db migrate status # Show migration status
nself db migrate create <name> # Create a new migration file
nself db migrate verify-checksums # Verify migration file checksums
nself db migrate reset-checksum <id> # Reset a single migration checksumManage and run seed data. Seed files are idempotent and environment-aware.
nself db seed run # Run all pending seed files
nself db seed list # List seed files and their status
nself db seed verify # Verify seed file checksums
nself db seed graph # Show seed dependency graphCreate a database backup. Backup file defaults to a timestamped name in the current directory.
nself db backup # Backup to timestamped file
nself db backup mybackup.sql # Backup to named fileRestore from a backup file.
nself db restore mybackup.sqlOpen an interactive PostgreSQL shell (psql) connected to the running database container.
nself db shell # Open psql
# Then run any SQL:
# SELECT * FROM np_users LIMIT 10;
# dt np_*Drop the current database. Requires confirmation.
nself db dropDrop and recreate the database. Runs all migrations and seeds fresh.
nself db resetList all databases in the PostgreSQL instance.
nself db listHasura metadata management and console access.
nself db hasura console # Open Hasura console in browser
nself db hasura metadata apply # Apply metadata from files
nself db hasura metadata export # Export current metadata
nself db hasura metadata reload # Reload metadata
nself db hasura metadata diff # Show metadata diff
nself db hasura metadata validate # Validate metadata
nself db hasura metadata lint # Lint metadata files
nself db hasura git status # Show metadata git status
nself db hasura git pull # Pull metadata from remote
nself db hasura git push # Push metadata to remoteRow-Level Security policy audit and application. Security-Always-Free — no license required.
nself db rls audit # Audit all tables for RLS gaps
nself db rls apply # Apply recommended RLS policies
nself db rls apply-table <schema> <table> # Apply RLS to one table
nself db rls rollback <schema> <table> # Roll back RLS on one tablePoint-in-Time Recovery management for PostgreSQL WAL archiving.
nself db pitr status # PITR status and last archive time
nself db pitr enable # Enable WAL archiving
nself db pitr test # Test archive connectivity
nself db pitr restore # Restore to a point in time
nself db pitr backup-sync # Sync backup to remote
nself db pitr backup-sync-status # Check sync status
nself db pitr restore-drill # Practice a restore
nself db pitr restore-drill-list # List restore drill recordsPgBouncer connection pool management.
nself db pgbouncer status # Connection pool status
nself db pgbouncer generate # Generate pgbouncer.ini config
nself db pgbouncer connection-url # Show the pooled connection URLAudit migration idempotency and schema drift.
nself db audit idempotent <file> # Check a migration file for idempotency
nself db audit drift scan # Scan for schema drift vs migrations
nself db audit drift fix [schema table] # Fix detected driftScaffold soft-delete patterns (deleted_at, is_deleted, row-level filtering) for tables.
nself db soft-delete audit # Find tables without soft-delete
nself db soft-delete apply <schema> <table> # Add soft-delete to a table
nself db soft-delete generate <schema> <table> # Generate migration only (no apply)Audit and apply missing indexes on foreign key columns.
nself db fk-index audit # Find FK columns without indexes
nself db fk-index apply # Add missing indexesManage deterministic test fixtures for development and CI.
nself db fixtures list # List available fixture sets
nself db fixtures run <name> # Load a fixture set
nself db fixtures verify <name> # Verify fixture integritynself generate — generate TypeScript/Go/Python/Dart/Swift types from Hasura schema