Skip to content

CLI Commands

CommandDescription
alab initInitialize new project
alab table <namespace> <name>Create a new table schema file
alab new <name>Generate migration from schema changes
alab migrateApply pending migrations
alab rollback [n]Rollback last n migrations (default: 1)
alab statusShow migration status
alab historyShow applied migrations with execution details
alab diffShow schema vs database diff
alab checkValidate schema files
alab verifyVerify migration chain integrity
alab exportExport to OpenAPI/GraphQL/TypeScript/Go/Python/Rust
alab httpStart live documentation server
alab typesRegenerate IDE autocomplete definitions
alab resetDrop all tables and re-run migrations (dev only)
alab schema --at <rev>Show schema at a specific migration revision
alab rebuild-cacheRebuild local cache from migration files
Terminal window
# Initialize a new project
alab init
# Create a new table schema file (normalized to snake_case)
alab table auth User # Creates schemas/auth/user.js
alab table Blog PostComment # Creates schemas/blog/post_comment.js
# Create a migration after schema changes
alab new add_users_table
# Preview SQL without executing
alab migrate --dry
# Apply all pending migrations
alab migrate
# Rollback the last 3 migrations
alab rollback 3
# Check current migration status
alab status
# Validate schema files before committing
alab check
# Verify migration chain integrity
alab verify
FlagCommandDescription
--drymigrate, rollbackPreview SQL without executing
--forcemigrateSkip safety warnings
--jsonstatusJSON output for CI/CD pipelines
-f allexportExport all formats
--mergeexportSingle file per format
-p <port>httpCustom port (default: 8080)
Terminal window
alab migrate --dry # Preview SQL without executing
alab rollback --dry # Preview rollback SQL
alab status --json # JSON output for CI/CD
alab export -f all # Export all formats
alab export -f all --merge # Single file per format
alab http -p 3000 # Custom port

The table command creates a new table schema file with proper directory structure:

Terminal window
alab table <namespace> <table_name>

Both namespace and table_name are automatically normalized to lowercase snake_case:

InputCreates
alab table auth Userschemas/auth/user.js
alab table Blog post-itemschemas/blog/post_item.js
alab table API UserProfileschemas/api/user_profile.js

The generated file includes a basic template with common fields commented out:

schemas/auth/user.js
export default table({
// id: col.id(),
// name: col.string(100),
// email: col.email().unique(),
// is_active: col.flag(true),
// status: col.enum(["active", "inactive"]).default("active"),
// author: col.belongs_to("auth.user"),
}).timestamps();