PostgreSQL
PostgreSQL is the default for transactional application data on Watasu. Use it whenever you need relational queries, transactions, migrations, or strong consistency.
Create a database
Section titled “Create a database”watasu addons:create postgresql --app my-appwatasu addons:wait my-databaseThat’s the minimum. Watasu provisions the database, attaches it, and exports connection vars to your app:
| Variable | Purpose |
|---|---|
DATABASE_URL | Full connection string |
PGHOST | Hostname |
PGPORT | Port |
PGDATABASE | Database name |
PGUSER | Username |
PGPASSWORD | Password |
Pick a plan
Section titled “Pick a plan”Plans range from cheap shared instances for development to dedicated high-availability tiers for production:
hobby-0,hobby-1— entry tier, manual backups, good for prototypingstandard-0…standard-4— production tier, scheduled backupspremium-1…premium-4— high availability, replication, larger storage
watasu addons:create postgresql:standard-0 --app my-appSee Add-on Plans for the full plan table with sizes, retention, and what’s included.
Open a psql session
Section titled “Open a psql session”watasu pg:psql DATABASE_URL --app my-appUse the env-var name (DATABASE_URL, or an alias like REPORTING_DATABASE_URL) to pick which database to connect to when an app has more than one.
Followers (read replicas)
Section titled “Followers (read replicas)”Followers are streaming replicas, useful for read-heavy reporting queries that you don’t want competing with primary traffic.
watasu pg:follow DATABASE_URL --app my-app --name reporting-db --plan standard-1 --region hel1Once the follower is provisioned and caught up, attach it like any other database:
watasu addons:attach reporting-db --app my-app --as REPORTINGYour app now has both DATABASE_URL and REPORTING_DATABASE_URL.
Backups
Section titled “Backups”PostgreSQL supports manual and scheduled backups, plus restore from either a managed backup or an uploaded dump file.
Capture a manual backup
Section titled “Capture a manual backup”watasu pg:backups:capture --app my-appList backups
Section titled “List backups”watasu pg:backups --app my-appRestore
Section titled “Restore”Restores create a new database (a replacement add-on), not an in-place overwrite. This is intentionally safer.
From a managed backup:
watasu pg:backups:restore b101 DATABASE_URL --app my-app --name db-restoredFrom a local dump file:
watasu pg:backups:restore ./production.dump DATABASE_URL --app my-app --name db-restoredPromote the restored database
Section titled “Promote the restored database”When the replacement is ready and you’ve verified it, promote it into the attachment role:
watasu pg:promote db-restored --app my-appThe app now points at the restored database under DATABASE_URL. The original is still around until you destroy it.
The full backup/restore loop is documented as a workflow in Backups and Restores.
- Take a manual backup before risky schema migrations.
- Use a follower as soon as analytics queries start affecting primary latency.
- Keep your application’s connection pool sized to fit the plan, not maxed out — many small pools beat one giant one.
- Run migrations through your deploy or release process, not from a workstation.