I’m looking for some guidance on how to best manage datasources on a per environment basis when it comes to deployments.
I have a Coldbox application that will be deployed to an already running instance of ACF 2023.
The source is in GitHub and I keep the entire code base in the repository.
Deploying to our staging environment is no problem because it uses the same datasource as the dev environment so all I need to do is get the code onto the server and everything works without issue.
The datasource will need to change when I deploy to production though.
Currently the datasource is set in application cfc:
this.datasource = “my_dev_db”;
This is nice because I don’t have to set the datasource attribute on cfquery tags for example.
Is there a way to setup my datasource in Coldbox on ACF that will make the config more flexible when changing environments?
I’m already using Coldbox environments for various other env specific configurations.
Is it possible to make use of environments to set the datasource also?
Perhaps not setting the datasource in application cfc and having a Coldbox setting for the datasource name and setting the datasource for each cfquery might work but I’d have to update many queries in that scenario.
Alternatively I’ve considered fetching the Coldbox environment setting in application cfc and switching the datasource there but I wasn’t sure if that could break the upgrade path and it doesn’t feel like the correct way to handle it. emphasized text
If you could point me in the right direction I’d appreciate any guidance on the best way to manage this.
Thanks in advance.