Quick Start
Get up and running with Astroladb in three simple steps: initialize, configure, and create your first schema.
Step 1: Initialize Project
Section titled “Step 1: Initialize Project”mkdir myapp && cd myappalab initThis creates the basic project structure with configuration files and sample directories.
Project Structure
Section titled “Project Structure”After running alab init, you’ll have:
myapp/├── alab.yaml # Configuration file├── schemas/ # Your schema definitions├── migrations/ # Generated SQL migrations└── types/ # TypeScript definitions for IDE support| File/Folder | Purpose |
|---|---|
alab.yaml | Database connection and project settings |
schemas/ | JavaScript files defining your tables |
migrations/ | Auto-generated SQL migration files |
types/ | TypeScript definitions for col and table autocomplete |
Step 2: Configure Database
Section titled “Step 2: Configure Database”Edit alab.yaml with your database connection:
PostgreSQL Configuration
Section titled “PostgreSQL Configuration”database: dialect: postgres url: postgres://user:password@localhost:5432/mydb
schemas: ./schemasmigrations: ./migrationsSQLite Configuration (for development)
Section titled “SQLite Configuration (for development)”database: dialect: sqlite url: ./dev.db
schemas: ./schemasmigrations: ./migrationsConfiguration Options
Section titled “Configuration Options”| Setting | Description | Example |
|---|---|---|
database.dialect | Database type | postgres or sqlite |
database.url | Connection string | See examples above |
schemas | Path to schema definitions | ./schemas |
migrations | Path to migration output | ./migrations |
Step 3: Create Your First Table
Section titled “Step 3: Create Your First Table”Use the alab table command to scaffold a new schema file:
alab table auth userThis creates schemas/auth/user.js with a basic template. Edit it to define your columns:
export default table({ id: col.id(), email: col.email().unique(), username: col.username().unique(), password: col.password_hash(), is_active: col.flag(true),}).timestamps();Step 4: Generate and Apply Migration
Section titled “Step 4: Generate and Apply Migration”Generate a migration from your schema:
alab new create_usersPreview the SQL before applying:
alab migrate --dryApply the migration to your database:
alab migrateWhat’s Next?
Section titled “What’s Next?”You now have a working Astroladb project! Here are some next steps:
- Create your first schema - Learn more about schema definitions
- Explore semantic types - Discover all available column types
- Learn about relationships - Connect tables with foreign keys
- Export types - Generate TypeScript, Go, or Python types
Common Patterns
Section titled “Common Patterns”Multiple Tables in One Namespace
Section titled “Multiple Tables in One Namespace”alab table blog postalab table blog commentalab table blog tagCreates:
schemas/blog/post.jsschemas/blog/comment.jsschemas/blog/tag.js
Different Namespaces
Section titled “Different Namespaces”alab table auth useralab table catalog productalab table orders orderOrganizes tables by domain: