A common pattern between development and production is a dev website will use sqlite, because it is zero setup, but then use PostgresSQL or MySQL in production. However, in the default Settings.hs scaffolding file generated by Yesod, only one persistent backend is specified. Is there a way to have the Development configuration use one persistent backend, and the Production configuration another? Additionally, these should have distinct database setting YAML files, so that a simple filename can be configured for sqlite, but production db credentials never hit the VCS repository.
I don't like this practice in general, as there can be subtle differences between database engines that don't show up until production. (This can be mitigated by having a staging server in-between.)
Anyway, you can certainly do this via conditional compilation, though the scaffolded site isn't designed to work that way out-of-the-box. Just look for all the places that refer to a specific backend and make it conditional on the DEVELOPMENT CPP variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With