Skip to content

Configuration

Astroladb uses a simple YAML configuration file for project settings and database connections.

Create alab.yaml in your project root:

database:
dialect: postgres # or sqlite
url: postgres://user:pass@localhost:5432/mydb
schemas: ./schemas
migrations: ./migrations
OptionDescriptionRequiredDefault
database.dialectDatabase type (postgres or sqlite)Yes
database.urlConnection stringYes
schemasPath to schema filesNo./schemas
migrationsPath to migration outputNo./migrations
# Database configuration
database:
dialect: postgres
url: postgres://myuser:mypass@localhost:5432/myapp_dev
# Project paths
schemas: ./schemas
migrations: ./migrations
# Optional: Export settings (future feature)
# exports:
# output: ./generated
# formats: [typescript, go, openapi]
VariableDescription
ALAB_DATABASE_URLOverrides database.url from config
Terminal window
# Use environment variable instead of config file
export ALAB_DATABASE_URL="postgres://user:pass@localhost:5432/mydb"
alab migrate

Standard connection string format:

postgres://username:password@hostname:port/database_name

Examples:

# Local development
database:
dialect: postgres
url: postgres://dev:dev123@localhost:5432/myapp_dev
# Production with SSL
database:
dialect: postgres
url: postgres://produser:securepass@prod.example.com:5432/myapp?sslmode=require
# With connection pooling parameters
database:
dialect: postgres
url: postgres://user:pass@localhost:5432/mydb?pool_max_conns=20
ParameterDescriptionExample
sslmodeSSL connection moderequire, disable
pool_max_connsMax connection pool size20
connect_timeoutConnection timeout in seconds10

SQLite uses file paths instead of connection strings:

# Relative path (recommended for development)
database:
dialect: sqlite
url: ./dev.db
# Relative path in subdirectory
database:
dialect: sqlite
url: ./data/local.db
# Absolute path
database:
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.

Never commit credentials to version control. Use environment variables in production:

database:
dialect: postgres
url: ${ALAB_DATABASE_URL}

Then set the environment variable:

Terminal window
export ALAB_DATABASE_URL="postgres://user:pass@prod.example.com:5432/myapp"