Erawanไทย

Make it real

A database — wired in for you

One command, and your app has Postgres with its connection string already in the environment. What is worth understanding is the part underneath: what you share with other accounts, what is only yours, and the one number you cannot change afterwards.

1. Attach it

erawan addon add my-app postgres

The app restarts with DATABASE_URL set. Any library that speaks Postgres reads it and connects — there is no Erawan-specific client.

2. What you actually get

Plan

Where it lives

Size

Free

shared instance

100 MB

Hobby

shared instance

500 MB

Pro

an instance of its own

1 GB

Max

an instance of its own

2 GB

On the shared instance your database is still yours: a database and a login role created for your app alone, with CONNECT revoked from everyone else. Postgres grants that to every new database by default, which would let any account open any other by name, so it is taken away deliberately. The role is also not a superuser — a superuser can read the whole instance and can run shell commands through COPY … FROM PROGRAM.

From Pro the instance is yours outright, and moving up physically copies the data: the destination is built, the rows are copied, the table and row counts are compared, and only then is the app repointed and the old one destroyed. Anything that fails before that last step leaves you on the database nobody touched.

3. The number you cannot change later

erawan addon add my-app postgres --size 1gb

Ask for less than your plan allows if you want to — the plan is a ceiling, not a quota you must spend. What you cannot do is change it afterwards: the storage class underneath cannot resize a volume that exists, so the size is a fact about the disk rather than about the plan you happen to be on today. Asking for a different one on an existing add-on is refused, with the way to actually do it.

The floor is 1 GB, and that is Postgres's own: its max_wal_size is 1 GB, so a smaller volume can fill with write-ahead log before it holds any of your rows.

4. Removing one, and the line that brings it back

erawan addon rm my-app postgres

That detaches it. But if your project carries an erawan.yaml with addons: [postgres] in it, the next deploy creates a new one — because that line is not a record of what you once did, it is the release saying what it needs before its first process starts. Take the line out of the manifest as well, or the removal lasts until your next deploy and no message tells you it did not stick.

The same declaration is why an app that needs a database does not have to crash first: without it the order would be deploy, watch it fail with no DATABASE_URL, provision, wait for a restart. It is left alone when the add-on already exists — minting a second password would leave the database on one value and the app holding the other.

5. Moving data in

erawan db import my-app dump.sql.gz

A gzipped pg_dump, restored into the app's own database. That is the path from a laptop, from another host, or from the version of this app you were running before.

All lessons

Add a Postgres database to your app — Erawan