Creating & Connecting a Database
Learn about Creating & Connecting a Database in WaymakerOS.
Two steps: provision the Postgres database, then connect it to your app so the app's code can reach it.
Create the database
- Open the Databases section of Host and click New Database (or open your app and use the Database tab).
- Choose the app it belongs to. Only apps that don't already have a database appear — each app gets one dedicated Postgres instance.
- Choose the region — where your data physically lives (Sydney, Singapore, Frankfurt, London, or N. Virginia).
- Click Provision.
The region is permanent. It's fixed for the life of the database and can't be changed later. Pick the region closest to your users, or the one your data-residency rules require, before you provision.
Your database is ready in moments. It starts empty — you add tables with migrations.
Connect it to your app
Creating the database doesn't automatically wire it to your app's code — you connect it, which makes your database reachable through a single environment variable:
- In the database view, click Connect to app (or run the connect step from your editor with the Waymaker tools).
- Waymaker adds
DATABASE_URLto your app's environment variables. Your code reads this automatically — Apps through@waymakeros/db, Ambassadors and Agents throughctx.postgres— so you never handle the raw connection details yourself. - Redeploy your app so it picks up the new environment variable.
That's it. After the redeploy, your app can query and write to its database. See Using Your Database in Code.
Good to know
- The connection is handled for you. Waymaker never shows or logs the raw connection string — your code reaches the database through
@waymakeros/db(Apps) orctx.postgres(Ambassadors and Agents), and the platform manages the credentials. - One database, one app. If you need data shared across two apps, expose it through an Ambassador or the Data API rather than trying to attach one database to two apps.
- Redeploy is required. Connecting sets an environment variable, and environment variables only take effect on the next deploy — the same as any other app setting.
Deleting a database
You can delete a database from its Settings tab. This is permanent and can't be undone — you'll be asked to type "delete" to confirm. Everything in it is gone, so export anything you need first.
Next Steps
- Changing Your Schema — add your first tables
- Using Your Database in Code — read and write from your app
- The Database Workspace — browse and query