Databases
An app can have its own Postgres and Redis, on the same computer, reachable only from that app. It finds them in its environment.
Turn one on
In the app's folder:
$ secretbase database postgres on
It says "Postgres is on for my-app: your app gets DATABASE_URL." Your app reads the address from DATABASE_URL (REDIS_URL for Redis, with secretbase database redis on). A running app moves to it at once. From another folder, name the app: secretbase database my-app postgres on.
- Postgres 17 and Redis 7, each in its own sandbox next to the app, with no internet of its own.
- Postgres keeps 512 MB of memory for itself, Redis 128 MB.
- Both are in the app's backups while they are on.
secretbase database my-appshows which are on.
Plain Postgres and Redis are for web apps (an app with its own server). A website gets a database only with Backend: Postgres with the Data API, which its browser code reaches with the publishable key:
$ secretbase database my-app postgres on This project is a website, so it has no app to use Postgres on its own. A website gets a database with its Supabase features: `secretbase backend my-app on`. (HB-DATABASE-010)
Turn one off
secretbase database postgres off stops it: "Postgres is off for my-app. Its data is kept on this computer until you delete the app; it isn't backed up." Turn it on again and the app finds its data where it was.
PostGIS, for maps and places
$ secretbase database postgis on
The app's Postgres then runs with PostGIS, with its data. This is one way: a database with PostGIS keeps it. To stop the database, turn Postgres off.
Database changes before each release
To change the database's tables before a new release takes visitors (a migration), add a release: line to the app's Procfile:
web: npm start release: npx prisma migrate deploy
On each publish, Secretbase runs that command once in the new release, with the app's keys and DATABASE_URL, before the release goes live. The publish shows "Runs your Procfile's release: line (npx prisma migrate deploy) before going live."
- If it fails, or still runs after 10 minutes, the new release doesn't go live: the release that was live stays live, and the publish ends with the command's last lines.
- Its output is in the app's logs, each line marked
[release]. - Undo and restore don't run it: they put a release back as it was. Undo doesn't put the database back; a restore does.
It works for Node, Python and Go apps and apps with their own Dockerfile.
Let an AI read it
An AI tool connected to Secretbase can read an app's Postgres with its sql tool: one query at a time, read-only, so nothing can be written. A query stops after 10 seconds and returns at most 1,000 rows and 100 KB. The rows are marked as data, never as instructions. It never reads the sign-in tables of a Backend app: passwords and sessions stay out.
To work on the database yourself with psql or a migration tool, see Connect from a laptop.
A database or service on your own network
An app reaches the internet but nothing on your own network, this computer included. To let it use one service there, such as a database on another machine or on this computer, give its address and port:
secretbase host-service shop 192.168.1.10:5432
- The app reaches that one address and port, nothing else on your network.
secretbase host-service shop offswitches it off. - Off at first. Only the app's owner sets it, on this computer: no token can.
- The service must accept connections from other machines: one that listens only on this computer's own loopback address isn't reached. If this computer's firewall blocks the port, allow it.
If something goes wrong
- "You have a key named
DATABASE_URL…": Secretbase sets that key itself. Remove yours (secretbase keys remove DATABASE_URL), then turn Postgres on. - "Your app's database (Postgres) keeps crashing" (HB-DATABASE-006): its last log lines are in
secretbase logs. - "<name> has a database, but what you published is a plain website…" (HB-DATABASE-013): publish the app with its server, or turn the database off.
- "A host service is an address and a port…" (HB-MACHINE-022): give an IPv4 address and a port, such as
192.168.1.10:5432.