CLI Commands
Command Reference
Section titled “Command Reference”| Command | Description |
|---|---|
alab init | Initialize new project |
alab table <namespace> <name> | Create a new table schema file |
alab new <name> | Generate migration from schema changes |
alab migrate | Apply pending migrations |
alab rollback [n] | Rollback last n migrations (default: 1) |
alab status | Show migration status |
alab history | Show applied migrations with execution details |
alab diff | Show schema vs database diff |
alab check | Validate schema files |
alab verify | Verify migration chain integrity |
alab export | Export to OpenAPI/GraphQL/TypeScript/Go/Python/Rust |
alab http | Start live documentation server |
alab types | Regenerate IDE autocomplete definitions |
alab reset | Drop all tables and re-run migrations (dev only) |
alab schema --at <rev> | Show schema at a specific migration revision |
alab rebuild-cache | Rebuild local cache from migration files |
Usage Examples
Section titled “Usage Examples”# Initialize a new projectalab init
# Create a new table schema file (normalized to snake_case)alab table auth User # Creates schemas/auth/user.jsalab table Blog PostComment # Creates schemas/blog/post_comment.js
# Create a migration after schema changesalab new add_users_table
# Preview SQL without executingalab migrate --dry
# Apply all pending migrationsalab migrate
# Rollback the last 3 migrationsalab rollback 3
# Check current migration statusalab status
# Validate schema files before committingalab check
# Verify migration chain integrityalab verifyCommon Flags
Section titled “Common Flags”| Flag | Command | Description |
|---|---|---|
--dry | migrate, rollback | Preview SQL without executing |
--force | migrate | Skip safety warnings |
--json | status | JSON output for CI/CD pipelines |
-f all | export | Export all formats |
--merge | export | Single file per format |
-p <port> | http | Custom port (default: 8080) |
alab migrate --dry # Preview SQL without executingalab rollback --dry # Preview rollback SQLalab status --json # JSON output for CI/CDalab export -f all # Export all formatsalab export -f all --merge # Single file per formatalab http -p 3000 # Custom portTable Command
Section titled “Table Command”The table command creates a new table schema file with proper directory
structure:
alab table <namespace> <table_name>Both namespace and table_name are automatically normalized to lowercase snake_case:
| Input | Creates |
|---|---|
alab table auth User | schemas/auth/user.js |
alab table Blog post-item | schemas/blog/post_item.js |
alab table API UserProfile | schemas/api/user_profile.js |
The generated file includes a basic template with common fields commented out:
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();