Postgres

A database in its own microVM, with credentials made in your browser and a backup every day.

Create a database

A database is a service of type postgres, and it needs a plan. Create one in a project and give it:

  • a name, such as db, which other services use to reference it,
  • a CPU and memory size,
  • a disk size, from your plan's disk.

wabi runs the official postgres image in the database's own microVM, on port 5432. It starts as soon as its credentials are signed, which the dashboard does as part of creating it.

Credentials

Your browser generates the credentials when you create the database: two passwords from 32 random bytes each, and the variables built from them and the database's private address. It seals them like any other variables and your wallet signs them as version 1. wabi never sees them in plaintext.

The database has two roles. app owns the database, and it is the role your services connect as. The postgres superuser is for the database's own microVM: it connects only over the local socket there, and from the network it is refused whatever password is offered.

VariableHolds
POSTGRES_USERpostgres, the superuser
POSTGRES_PASSWORDthe superuser's password
POSTGRES_DBthe database name
APP_DB_USERapp, the role that owns the database
APP_DB_PASSWORDthe app role's password
DATABASE_URLa connection URL for app at the database's private address
PGHOSTthe database's private address
PGPORT5432
PGUSERapp
PGPASSWORDthe app role's password
PGDATABASEthe database name

APP_DB_PASSWORD is given to the app role when the database is first made. Editing the variable afterwards doesn't change the role's password.

To see a value, open the database's variables and use Reveal with wallet. Your wallet signs a message that opens the read-back copy in your browser (Sealed variables).

Connect a service

Another service connects through a reference to the database's variables. In the app's variables, set:

DATABASE_URL=${{db.DATABASE_URL}}

db is the database's service name. The reference resolves inside the app's microVM when it starts, from the database's own sealed values, so the password never passes through wabi in plaintext. The connection runs over your private network. More in Sealed variables.

Extensions

app owns the database, so it creates the extensions Postgres marks as trusted, from the official image's contrib set:

pgcrypto, uuid-ossp, citext, hstore, pg_trgm, ltree, unaccent, btree_gin, btree_gist, fuzzystrmatch, intarray, tablefunc

CREATE EXTENSION IF NOT EXISTS pg_trgm; in a migration works as is. An extension that needs a superuser can't be created, and a dump that contains one can't be restored.

Size and disk

CPU, memory and disk count against your plan (Sizes). The disk only grows. Changing CPU or memory starts a new deployment, and redeploying restarts the database with its current settings.

Backups

wabi backs up every database once a day and keeps each backup for 7 days. You can also take a backup now, once the database has run and while no other backup is in progress.

A backup runs inside your tenant, your account's own space in wabi's cluster. The password is opened in a microVM there, the dump is encrypted to your tenant key before it leaves, and only the encrypted file is stored. Like your variables, a backup opens only inside your tenant.

The backup list shows each backup's time and size.

Restore

Choose a backup and restore it. Your wallet signs a restore grant for that backup, at the time its proof names (Rollbacks and older values); it is good for one hour and one restore. The restore runs inside your tenant, checks the backup's proof against this database, that backup and that time, opens it with your tenant key, and loads it into the live database as app: each table and other object in the backup is dropped and recreated from it.

Each backup carries a proof that only your tenant can make, naming the database, the backup and its time, so a restore loads only a backup of this database that your tenant made.

The restore shows running, then succeeded or failed. One restore runs at a time. To keep the current state as well, take a backup now before you restore.

Public access

A database is reachable only from your private network until you turn on public access. Then wabi opens a port for it in the range 30000–30999 and shows its endpoint:

edge.projectwabi.app:30412

The dashboard assembles the public connection string from that endpoint and the app role's read-back password, in your browser. It is not stored as a variable. With it, connect from anywhere:

psql "postgresql://<user>:<password>@edge.projectwabi.app:30412/<database>"

Turning public access off closes the port.

Deleting a database

Deleting the database service deletes its volume and all its backups.