build / databases
Databases
Postgres as services of your project, as many as it needs, with MySQL and Valkey coming next: a db and a cache, or a second database for analytics. Each is only for its project, closed by default, encrypted and copied every night.
Create one
$ 00b5e2 db create --engine postgres --name db
■ db (postgres 17) ready in development, closed
DATABASE_URL injected into the services that use db
$ 00b5e2 db create --engine valkey --name cache
■ cache (valkey 8, coming next) ready, CACHE_URL injected
$ 00b5e2 db create --engine postgres --name db --prod
■ db ready in production
Engines
| engine | version | good for |
|---|---|---|
| postgres | 17 | Most apps: relational data, JSON, full text search |
| mysql | 8.4 | Apps that expect MySQL. Coming next |
| valkey | 8 | Cache, queues and sessions. Coming next |
Connect from your machine
A database is closed by default: only the services of its project reach it, by name (db:5432), with the variables described in Connecting services. To use it from your machine for a moment, open a tunnel through the CLI:
$ 00b5e2 db connect db
tunnel open on localhost:5432 (ctrl+c to close)
$ psql postgres://localhost:5432/db
Use a database from outside 00b5e2
To host only the database here and the app elsewhere, open it. Its address db.my-site.00b5e2.app is reserved; opened, it gets its own port on the shared host, because many clients don't send the hostname. Defences are on by default: TLS required, a long generated password, a limit on login attempts and an alert email after many failures. An IP allowlist is recommended.
$ 00b5e2 services open db --allow 203.0.113.0/24
■ open at postgres://db_user:•••@db.my-site.00b5e2.app:31842/db?sslmode=require
TLS required, password generated, owners told by email
$ 00b5e2 services close db
■ closed db:5432 inside my-site only
Closing it releases the port and the outside password stops working at once. Services inside my-site keep using DATABASE_URL the whole time.
Backups
Every night at 03:00 UTC each database is copied, encrypted, to R2. Development and production are kept apart.
$ 00b5e2 db backups ls db --prod --json
[ { "date": "2026-11-23T03:00:00Z", "size": "184 MB" },
{ "date": "2026-11-22T03:00:00Z", "size": "183 MB" } ]
Restore by date
$ 00b5e2 db restore db --date 2026-11-22 --prod
copying the current data first
■ db restored to 2026-11-22 03:00 UTC
A restore copies the current data first, so you can go back if you picked the wrong date. Restoring production is always explicit and, for an agent, needs a token with the db and deploy:prod scopes.
From an agent
| tool | what it does |
|---|---|
| create_database | Create a Postgres service. MySQL and Valkey coming next |
| list_backups | Nightly backups of a database, by date |
| restore_database | Restore a database to a date |
| open_service | Open a database at its own port, with TLS and a generated password |
| close_service | Close it again and release the port |