elements
Start Docs Blog Demos UI Pricing
Elements Manual
  • Getting Started
    • Project Layout
    • At a Glance
    • More Patterns
    • Database and Migrations
    • Conventions
    • Deploy, Licensing, Support
  • CLI
  • Build
  • Browser
  • Packages
  • TypeScript
  • Elements HTML
  • Assets
  • RPC
  • Router
  • Session
  • Database
  • Migrations
  • LiveTable
  • Channel
  • Jobs
  • Email
  • Payments
  • JSON
  • Async
  • Style
  • UI
  • JSOC
  • Config
  • Tests
  • Logs
  • Deploy
  • Editors
  • Recipes
  • Licenses
  • Issues
  • Changelog
Manual / Getting Started/ Database and Migrations

Database and Migrations

elements man start/database

On This Page

  • Bundled Postgres
  • App and Test Databases
  • Migrations
  • Remote or Hosted Postgres

The bundled Postgres, writing a migration, and running it.

Bundled Postgres

The database is Postgres, and Elements bundles it. There is nothing to install. A per-machine elements-machine daemon runs a single Postgres cluster shared by all your projects; it is created automatically, kept healthy, and listens on loopback port 5433 (not the usual 5432, so it never collides with a Postgres you already run). Data is stored under ~/elements/db in development.

App and Test Databases

On the first build, the project connects to the daemon, the cluster is ensured ready, and your project's app database and test database are created automatically. The names derive from the project directory (MyApp → my_app and my_app_test), or from database.name in config.jsoc.

Migrations

Migrations are SQL files under app/migrations/, and applying them is part of the build loop. Save a migration and Elements applies it, to the test database first, then the app database. In development you can edit an applied migration and Elements rolls it back and replays it. On a deploy machine a migration runs exactly once and is frozen thereafter. Demo rows for local work go in a migration with the @migration env=development build tag; see elements man database/seeds.

Remote or Hosted Postgres

To use a remote or hosted Postgres, set DB_HOST (and the other DB_* values) in the active environment. Several app servers share one cluster this way, and every feature works across all of them. Full topics: elements man database, elements man migrations.

Prev More PatternsNext Conventions
Product
Manual Pricing Compare
Company
History Contact
Legal
Privacy Policy Acceptable Use Terms License Agreement
© Elements Dev Corporation 2026