SCHEMA - nself-org/cli GitHub Wiki
Schema management in nself is handled through two complementary tools: migrations (via nself db migrate) and the Hasura Console (via nself hasura). There is no standalone nself db schema subcommand — schema operations are surfaced through the appropriate tool depending on the operation.
| Operation | Command |
|---|---|
| Apply pending migrations | nself db migrate |
| Create a new migration | nself db migrate create <name> |
| Check migration status | nself db migrate status |
| Open the Hasura Console (GUI schema editor) | nself hasura console |
| Apply Hasura metadata | nself hasura metadata apply |
| Export current Hasura metadata | nself hasura metadata export |
| Run Hasura migrations directly | nself hasura migrate apply |
| Open a raw database shell | nself db shell |
Migrations are SQL files that evolve your database schema over time. They live in the migrations/ directory of your nself project.
nself db migratenself db migrate statusShows which migrations have been applied and which are pending.
nself db migrate create add_user_preferencesCreates a new timestamped SQL file in migrations/. Edit the file to add your schema changes, then run nself db migrate to apply it.
nself db migrate rollback
nself db migrate rollback --steps 3 # Roll back 3 migrationsSee Database Workflow Guide for the complete migration workflow, including environments, conflict resolution, and CI/CD integration.
The Hasura Console provides a GUI for creating tables, columns, relationships, and permissions without writing SQL directly. Changes made in the Console are tracked as migrations automatically.
nself hasura consoleOpens the Hasura Console at http://localhost:9695 with migration tracking enabled. All GUI changes automatically create migration files in your migrations/ directory.
nself hasura metadata applyApplies relationship, permission, and event trigger configuration from metadata/ to your running Hasura instance.
nself hasura metadata exportExports the current Hasura configuration (tables, relationships, permissions) to the metadata/ directory so it can be version-controlled.
For ad-hoc schema inspection or one-off queries:
nself db shellOpens a psql session connected to your project database. Use this for inspection only — prefer migrations for any schema changes you want to track.
-- List all tables
\dt
-- Describe a specific table
\d users
-- Show table columns
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name = 'users'
ORDER BY ordinal_position;- Open Hasura Console:
nself hasura console - Create/modify tables and relationships using the GUI
- Console auto-generates migration files in
migrations/ - Commit migration files to version control
- Apply to staging:
nself deploy staging(runs migrations automatically) - Apply to production:
nself deploy production
- Create migration file:
nself db migrate create <description> - Edit the generated
.sqlfile with your DDL - Apply locally:
nself db migrate - Update Hasura metadata if new tables/relationships were added:
nself hasura metadata apply - Commit both migration + metadata files
- Deploy to environments
- Database Workflow Guide — Full migration workflow
-
Hasura Command Reference — All
nself hasurasubcommands -
Database Command Reference — All
nself dbsubcommands - Backup & Restore — Schema backups and point-in-time recovery