Configuring local development with Postgres and DATABASE_URL

Looking for advice on how to do the following:

In my production environment, I want to use the Postgres DB. As a result, I’m referencing the DATABASE_URL environment variable.

However, I also want to be able to deploy locally on my machine, as well as a staging environment. This means that when I run locally, I want to override DATABASE_URL to a local Postgres DB on my development machine, and to a different database in my staging enviroment.

I had been planning on simply using different toml files for each deployment, and setting the environment variables there. However, I see that secrets override environment variables, so I’m not sure what the best practice is for doing this with different DBs.

For additional context, I was not planning on using different organizations on if I could help it

For staging and prod we recommend always use secrets for sensitive data instead of environment variables. Making a prod and staging app would make life easier as you can have the same secret name but different values for each one and you can scale them differently.

For local development I’ll recommend you direnv, it’s very easy to use! Folks that work here use it a lot.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.