Databases
Create, attach, and manage databases across providers.
Overview
Relight manages Postgres databases on multiple providers:
| Provider | Service | Type |
|---|---|---|
gcp | Cloud SQL (Postgres) | GCP native |
aws | RDS (Postgres) | AWS native |
azure | Flexible Server (Postgres) | Azure native |
do | Managed Databases (Postgres) | DigitalOcean |
All providers use managed Postgres for unified backup, migration, and export across clouds.
List databases
relight db
relight db --db do # filter by provider
relight db --json
Create a database
relight db create mydb
relight db create mydb --db aws
relight db create mydb --db do
relight db create mydb --location enam
For full-stack providers (GCP, AWS, Azure), this creates a database on a shared Postgres instance. If no shared instance exists, Relight creates one first.
For DigitalOcean, this creates a database on a Managed Databases cluster.
Attach to an app
relight db attach mydb myapp
This:
- Creates a per-app database user with isolated permissions
- Injects
DATABASE_URLinto the app’s env vars
You can attach the same database to multiple apps. Each app gets its own user with independent credentials.
Detach from an app
relight db detach myapp
Removes the per-app database user, revokes its permissions, and removes the injected env vars.
Connect directly
relight db shell mydb # interactive SQL REPL
relight db query mydb "SELECT 1" # run a single query
relight db query mydb "SELECT 1" --json # JSON output
Import and export
relight db import mydb backup.sql # import a .sql file
relight db export mydb # dump to stdout
relight db export mydb -o backup.sql # dump to file
Credentials
relight db info mydb # show connection details
relight db token mydb # show auth token
relight db token mydb --rotate # rotate credentials
Reset (drop all tables)
relight db reset mydb
relight db reset mydb --confirm mydb # skip prompt
Destroy
relight db destroy mydb
relight db destroy mydb --confirm mydb
Detach all apps first. On full-stack providers, this drops the database from the shared instance and removes all per-app users.
Per-app user isolation
When you attach a database to an app, Relight creates a Postgres user named app_<dbname>_<appname> with:
CONNECTon the databaseUSAGEon the public schemaALL PRIVILEGESon all tables and sequencesALTER DEFAULT PRIVILEGESso the app user can access future tables
Each app’s user is independent. Detaching revokes all privileges and drops the user. Destroying the database cleans up all per-app users automatically.