Headless Mode
Run noorm without the TUI. Perfect for CI/CD pipelines, scripts, and automation.
noorm -H run build
noorm -H --json change ffWhen It Activates
noorm automatically runs headless when:
| Condition | Headless? |
|---|---|
-H or --headless flag | Yes |
NOORM_HEADLESS=true | Yes |
| CI environment detected | Yes |
| No TTY (piped output) | Yes |
-T or --tui flag | No (forces TUI) |
Detected CI environments:
- GitHub Actions (
GITHUB_ACTIONS) - GitLab CI (
GITLAB_CI) - CircleCI (
CIRCLECI) - Travis CI (
TRAVIS) - Jenkins (
JENKINS_URL) - Buildkite (
BUILDKITE) - Generic (
CIorCONTINUOUS_INTEGRATION)
Flags
| Flag | Short | Description |
|---|---|---|
--headless | -H | Force headless mode |
--tui | -T | Force TUI mode |
--json | — | Output JSON |
--config | -c | Config name to use |
--force | -f | Skip checksum checks |
--yes | -y | Skip confirmations |
--dry-run | — | Preview without executing |
Configuration
Using a Stored Config
# Use active config
noorm -H run build
# Use specific config
noorm -H --config staging run build
# Or via environment
export NOORM_CONFIG=staging
noorm -H run buildEnvironment-Only Mode
No stored config needed. Set connection via environment variables:
export NOORM_CONNECTION_DIALECT=postgres
export NOORM_CONNECTION_HOST=db.example.com
export NOORM_CONNECTION_DATABASE=myapp
export NOORM_CONNECTION_USER=deploy
export NOORM_CONNECTION_PASSWORD=$DB_PASSWORD
noorm -H run buildMinimum required:
NOORM_CONNECTION_DIALECT(postgres, mysql, sqlite, mssql)NOORM_CONNECTION_DATABASE
All Environment Variables
Connection:
NOORM_CONNECTION_DIALECT # postgres, mysql, sqlite, mssql
NOORM_CONNECTION_HOST # Database host
NOORM_CONNECTION_PORT # Database port
NOORM_CONNECTION_DATABASE # Database name
NOORM_CONNECTION_USER # Username
NOORM_CONNECTION_PASSWORD # PasswordPaths:
NOORM_PATHS_SQL # Schema directory (default: ./sql)
NOORM_PATHS_CHANGES # Changes directory (default: ./changes)Behavior:
NOORM_CONFIG # Config name to use
NOORM_YES # Skip confirmations (1 or true)
NOORM_JSON # Output JSON (1 or true)
NOORM_HEADLESS # Force headless mode
NOORM_DEBUG # Enable debug loggingCommands
Schema Operations
run build
Execute all SQL files in the schema directory.
noorm -H run build
noorm -H --force run build # Skip checksums, run everything
noorm -H --dry-run run build # Preview without executingText output:
Building schema...
✓ sql/01_tables/001_users.sql
✓ sql/01_tables/002_posts.sql
• sql/02_views/001_recent.sql (unchanged)
Executed: 2
Skipped: 1JSON output:
{
"status": "success",
"filesRun": 2,
"filesSkipped": 1,
"filesFailed": 0,
"durationMs": 234
}run file <path>
Execute a single SQL file.
noorm -H run file sql/01_tables/001_users.sqlrun dir <path>
Execute all SQL files in a directory.
noorm -H run dir sql/01_tables/Change Operations
change
List all changes with status.
noorm -H changeText output:
Changes:
✓ 2024-01-15-init-schema Applied
✓ 2024-01-20-add-roles Applied
○ 2024-02-01-notifications PendingJSON output:
[
{"name": "2024-01-15-init-schema", "status": "applied"},
{"name": "2024-01-20-add-roles", "status": "applied"},
{"name": "2024-02-01-notifications", "status": "pending"}
]change ff
Fast-forward: apply all pending changes.
noorm -H change ff
noorm -H --dry-run change ff # Preview onlyJSON output:
{
"status": "success",
"applied": 2,
"skipped": 0,
"failed": 0,
"changes": [
{"name": "2024-02-01-notifications", "status": "success", "durationMs": 45}
]
}change run <name>
Apply a specific change.
noorm -H change run 2024-02-01-notificationschange revert <name>
Revert a specific change.
noorm -H change revert 2024-02-01-notificationschange history
View execution history.
noorm -H change historyDatabase Operations
db explore
Get schema overview.
noorm -H db exploreJSON output:
{
"tables": 12,
"views": 3,
"indexes": 8,
"functions": 2,
"procedures": 0
}db explore tables
List all tables.
noorm -H db explore tablesdb explore tables detail <name>
Describe a specific table.
noorm -H db explore tables detail usersJSON output:
{
"name": "users",
"columns": [
{"name": "id", "type": "integer", "nullable": false, "primaryKey": true},
{"name": "email", "type": "varchar(255)", "nullable": false}
]
}db truncate
Wipe all data, keep schema.
noorm -H -y db truncatedb teardown
Drop all database objects.
noorm -H -y db teardownProtected Configs
db teardown is blocked on protected configs. Use --force to override (be careful!).
Lock Operations
lock status
Check if database is locked.
noorm -H lock statuslock acquire
Acquire a lock.
noorm -H lock acquire --reason "Deploying v2.0"lock release
Release the lock.
noorm -H lock releaseExit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Error (check stderr or JSON output) |
CI/CD Examples
GitHub Actions
name: Database Changes
on:
push:
branches: [main]
jobs:
migrate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install noorm
run: npm install -g @noormdev/cli
- name: Apply changes
env:
NOORM_CONNECTION_DIALECT: postgres
NOORM_CONNECTION_HOST: ${{ secrets.DB_HOST }}
NOORM_CONNECTION_DATABASE: ${{ secrets.DB_NAME }}
NOORM_CONNECTION_USER: ${{ secrets.DB_USER }}
NOORM_CONNECTION_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: |
noorm -H run build
noorm -H change ffGitLab CI
migrate:
stage: deploy
image: node:20
script:
- npm install -g @noormdev/cli
- noorm -H run build
- noorm -H change ff
variables:
NOORM_CONNECTION_DIALECT: postgres
NOORM_CONNECTION_HOST: $DB_HOST
NOORM_CONNECTION_DATABASE: $DB_NAME
NOORM_CONNECTION_USER: $DB_USER
NOORM_CONNECTION_PASSWORD: $DB_PASSWORDGeneric CI Pattern
#!/bin/bash
set -e
# Install
npm install -g @noormdev/cli
# Configure via environment
export NOORM_CONNECTION_DIALECT=postgres
export NOORM_CONNECTION_HOST=$DB_HOST
export NOORM_CONNECTION_DATABASE=$DB_NAME
export NOORM_CONNECTION_USER=$DB_USER
export NOORM_CONNECTION_PASSWORD=$DB_PASSWORD
# Build schema
noorm -H run build
# Apply changes
noorm -H change ff
# Verify
noorm -H --json db exploreTest Database Setup
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: test
POSTGRES_DB: test_db
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm install -g @noormdev/cli
- name: Setup test database
env:
NOORM_CONNECTION_DIALECT: postgres
NOORM_CONNECTION_HOST: localhost
NOORM_CONNECTION_DATABASE: test_db
NOORM_CONNECTION_USER: postgres
NOORM_CONNECTION_PASSWORD: test
run: |
noorm -H run build
noorm -H change ff
- run: npm testScripting with JSON
Parse JSON output for programmatic use:
# Check if there are pending changes
pending=$(noorm -H --json change | jq '[.[] | select(.status == "pending")] | length')
if [ "$pending" -gt 0 ]; then
echo "Found $pending pending changes"
noorm -H change ff
fi# Get table count
tables=$(noorm -H --json db explore | jq '.tables')
echo "Database has $tables tables"