Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Breaking up the database values from DATABASE_URL is problematic on Heroku #3

Open
kreynen opened this issue Jul 10, 2020 · 1 comment

Comments

@kreynen
Copy link

kreynen commented Jul 10, 2020

username: env('DATABASE_USERNAME', 'strapi'),

https://devcenter.heroku.com/articles/connecting-to-heroku-postgres-databases-from-outside-of-heroku#credentials

I don't know how often Heroku makes changes large enough to require resetting the DATABASE_URL value, but breaking up the values of an environmental variable that Heroku automatically sets and updates into user configurable environmental values like DATABASE_PORT will result in a broken app until someone resets those any time this happens.

I looked at the Strapi code to see what it would take to parse the values from DATABASE_URL instead of setting the individual values in the database.js file. Unfortunately I don't think the database.js is as flexible as Drupal's settings.php that can process any PHP. Strapi includes some basic logic in examples in https://strapi.io/documentation/3.0.0-beta.x/concepts/configurations.html#usage, they also reference being "inspired by" https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals. According to Mozilla's template literals documentation, Tags allow you to parse template literals with a function. I don't know it that's an option in the Strapi implementation since it's only "inspired by" the standard.

I know that setting values for DATABASE_PORT is what Strapi recommends in their documentation, but unless we can get this to work with only DATABASE_URL or have a better understanding of when/why/how often Heroku updates the Postgres this approach will likely result in unexpected outages.

@alexfinnarn
Copy link
Contributor

strapi/strapi#3094 (comment)

Seems like there is a solution for now that I will test.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants