Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Database

Use SQL migrations + ATL_DATABASE_URL. Development usually starts with SQLite; production often uses Postgres.

1. Configure

export ATL_DATABASE_URL="sqlite:./tmp/app.db?mode=rwc"
# production example:
# export ATL_DATABASE_URL="postgres://user:pass@host:5432/dbname"

2. Migrate

atlantus db migrate --path .

Migrations live under db/migrations/ (created by atlantus new or your team’s templates).

3. From handlers

Use the runtime’s DB built-ins (names validated by atlantus check on your binary). Pattern:

get "/users/{id}" {
  def show(req) {
    let id = req.param("id")
    let user = /* db_query_one / project helper for users by id */
    if user is none {
      return json({ "error": "not_found" }, 404)
    }
    return json(user)
  }
}

Prefer putting SQL access in app/repositories/ or app/services/ and keeping routes thin — that is what atlantus new scaffolds toward.

Checklist

StepCommand / env
URLATL_DATABASE_URL
Schemaatlantus db migrate --path .
Serveatlantus dev --path .

Production notes

  • Run migrations in deploy before atlantus start
  • Do not commit secrets; inject via env
  • Prefer Postgres for multi-node

Next: Auth · Natives.