Postgres databases
Add a managed Postgres database to a project; its connection string lands in your environment.
Each project can have one managed Postgres database. Lahyer creates it in a few seconds and puts its connection string in an environment variable, so your next deployment can use it.
Add a database
On the project's Database tab, choose Add database. The connection string goes into DATABASE_URL unless you pick another name. From the terminal:
lahyer db create # or: lahyer db create --variable POSTGRES_URL
lahyer db # status, host, connections and sizeThe variable is set for production and previews, which share the database. It is marked Set by your database on the Environment variables tab and stays in step with the database: removing the database removes the variable.
Redeploy after adding a database so the running app picks up the variable.
Connect
The connection string has the form:
postgresql://<user>:<password>@<host>:<port>/<database>?sslmode=require- Connections must use TLS; the connection string already asks for it.
- The database is reachable from anywhere over TLS, so you can also connect from your laptop with
psqlor a GUI client. Choose Show connection string on the Database tab, or runlahyer db url. Each reveal is recorded in the audit log.
psql "$(lahyer db url)"Plan limits
| Free | Pro | |
|---|---|---|
| Databases per organization | 1 | 10 |
| Connections at a time, per database | 10 | 25 |
| Expected size, per database | 1 GB | 10 GB |
The Database tab shows the size and open connections. The size is a guide that Lahyer shows and reports on, not a hard stop. Use a connection pool in your app and keep it under the connection limit.
Remove a database
On the Database tab, remove the database and confirm by typing its name, or run lahyer db rm --yes. This deletes the database and everything in it, and removes its variable from the environment. Only owners and admins can remove a database.