Configuration
Astroladb uses a simple YAML configuration file for project settings and database connections.
Configuration File
Section titled “Configuration File”Create alab.yaml in your project root:
database: dialect: postgres # or sqlite url: postgres://user:pass@localhost:5432/mydb
schemas: ./schemasmigrations: ./migrationsConfiguration Options
Section titled “Configuration Options”| Option | Description | Required | Default |
|---|---|---|---|
database.dialect | Database type (postgres or sqlite) | Yes | — |
database.url | Connection string | Yes | — |
schemas | Path to schema files | No | ./schemas |
migrations | Path to migration output | No | ./migrations |
Full Example
Section titled “Full Example”# Database configurationdatabase: dialect: postgres url: postgres://myuser:mypass@localhost:5432/myapp_dev
# Project pathsschemas: ./schemasmigrations: ./migrations
# Optional: Export settings (future feature)# exports:# output: ./generated# formats: [typescript, go, openapi]Environment Variables
Section titled “Environment Variables”| Variable | Description |
|---|---|
ALAB_DATABASE_URL | Overrides database.url from config |
# Use environment variable instead of config fileexport ALAB_DATABASE_URL="postgres://user:pass@localhost:5432/mydb"alab migrateConnection Strings
Section titled “Connection Strings”PostgreSQL
Section titled “PostgreSQL”Standard connection string format:
postgres://username:password@hostname:port/database_nameExamples:
# Local developmentdatabase: dialect: postgres url: postgres://dev:dev123@localhost:5432/myapp_dev
# Production with SSLdatabase: dialect: postgres url: postgres://produser:securepass@prod.example.com:5432/myapp?sslmode=require
# With connection pooling parametersdatabase: dialect: postgres url: postgres://user:pass@localhost:5432/mydb?pool_max_conns=20Common PostgreSQL Parameters
Section titled “Common PostgreSQL Parameters”| Parameter | Description | Example |
|---|---|---|
sslmode | SSL connection mode | require, disable |
pool_max_conns | Max connection pool size | 20 |
connect_timeout | Connection timeout in seconds | 10 |
SQLite
Section titled “SQLite”SQLite uses file paths instead of connection strings:
# Relative path (recommended for development)database: dialect: sqlite url: ./dev.db
# Relative path in subdirectorydatabase: dialect: sqlite url: ./data/local.db
# Absolute pathdatabase: dialect: sqlite url: /var/lib/myapp/database.db
# In-memory (testing only - data lost on exit)database: dialect: sqlite url: ":memory:"Note: SQLite databases are single files. The directory must exist before running migrations.
Connection String Security
Section titled “Connection String Security”Never commit credentials to version control. Use environment variables in production:
database: dialect: postgres url: ${ALAB_DATABASE_URL}Then set the environment variable:
export ALAB_DATABASE_URL="postgres://user:pass@prod.example.com:5432/myapp"