CUCentralAdvancement / strapi-cms

Headless CMS candidate for potentially multiple apps
MIT License
0 stars 0 forks source link

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

Open kreynen opened 4 years ago

kreynen commented 4 years ago

https://github.com/CUCentralAdvancement/strapi-cms/blob/db024b85e7069d5c54d6ad928c64352c72418d02/config/database.js#L11

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 commented 4 years ago

https://github.com/strapi/strapi/issues/3094#issuecomment-581095733

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