Astroladb
Language-agnostic database migration tool with JavaScript DSL. Define your schema once, generate migrations and type exports for any language.
No ORM. No framework lock-in. Just clean migrations and type-safe exports.
Quick Example
Section titled “Quick Example”Define your schema using semantic types and relationships:
export default table({ id: col.id(), email: col.email().unique(), username: col.username().unique(), password: col.password_hash(), is_active: col.flag(true),}).timestamps();Generate migrations and export types with simple commands:
# Create migration from schemaalab new create_users
# Apply to databasealab migrate
# Export types for all languagesalab export -f allWhy Astroladb?
Section titled “Why Astroladb?”| Problem | Astroladb Solution |
|---|---|
| ORMs lock you into one language | Define once, use everywhere |
| Manual SQL migrations are error-prone | Auto-generate from schema definitions |
| Types drift from database | Always synchronized via single source |
| API docs get out of sync | OpenAPI/GraphQL generated from schema |
| Schema changes across microservices | Export to Go, TypeScript, Python, Rust |
Key Features
Section titled “Key Features”🎯 Schema-First Design
Section titled “🎯 Schema-First Design”Your JavaScript schema definitions are the single source of truth:
export default table({ title: col.title(), price: col.money(), category: col.belongs_to("catalog.category"),}).timestamps();🚀 Multi-Language Exports
Section titled “🚀 Multi-Language Exports”Generate type-safe code for your entire stack:
- TypeScript - Frontend and Node.js
- Go - Backend services
- Python - Data pipelines and APIs
- Rust - High-performance services
- OpenAPI - API documentation
- GraphQL - GraphQL schemas
🔒 Type Safety Everywhere
Section titled “🔒 Type Safety Everywhere”Change your schema once, types update everywhere:
alab export -f all# ✓ TypeScript interfaces updated# ✓ Go structs updated# ✓ Python dataclasses updated# ✓ OpenAPI spec updated🌊 Semantic Types
Section titled “🌊 Semantic Types”Pre-configured column types with built-in validation:
email: col.email().unique(), // Email pattern + uniqueprice: col.money(), // decimal(19,4), min(0)slug: col.slug(), // URL-safe, unique, patternis_active: col.flag(true), // boolean, default trueauthor: col.belongs_to("auth.user"), // Foreign key + indexSee all semantic types.
🔗 Relationships Made Easy
Section titled “🔗 Relationships Made Easy”// Foreign keysauthor: col.belongs_to("auth.user"),
// One-to-oneprofile: col.one_to_one("auth.user_profile"),
// Many-to-many (auto-creates join table).many_to_many("blog.tag")
// Polymorphictarget: col.belongs_to_any(["blog.post", "blog.comment"]),🎨 Developer Experience
Section titled “🎨 Developer Experience”- IDE Autocomplete - Full TypeScript definitions for DSL
- Validation - Catch errors before migration
- Dry Run - Preview SQL before applying
- Documentation Server - Live docs at
alab http - Version Control Friendly - Readable migration files
Supported Databases
Section titled “Supported Databases”| Database | Status | Use Case |
|---|---|---|
| PostgreSQL | ✅ | Production deployments |
| SQLite | ✅ | Development, testing, embedded |
Getting Started
Section titled “Getting Started”Ready to try Astroladb? Start with the installation guide:
- Installation - Install the CLI
- Quick Start - Create your first project
- First Schema - Define and migrate a table
- Semantic Types - Explore available column types
- Examples - See real-world schemas
Philosophy
Section titled “Philosophy”Astroladb follows these core principles:
- Schema is source of truth - Not the database, not the ORM
- Language-agnostic - Works with any language stack
- No magic - Generates readable SQL and types
- Developer-friendly - Great DX with autocomplete and validation
- Production-ready - Safe migrations with dry-run and verification