UserFrosting icon indicating copy to clipboard operation
UserFrosting copied to clipboard

Config for default database connection to use

Open lcharette opened this issue 7 years ago • 1 comments

Current configuration option let you define multiple database connection, but there no option to choose which one to use globally. This can be an issue with tests as they are run by default on the production database. The connection needs to be manually changed when writing tests.

(FYI, Laravel doesn't have this option either. Secondary database connection are defined as a per Model basis.)

A simple solution for tests would be to overwrite the default connection instead of a test_integration database for the testing env (N.B.: This wasn't implemented before since tests couldn't run migration, something currently supported in the feature-migrator branch).

While the same can be done by a sprinkle (Why change a config value in an env specific config file when you can simply overwrite the default db config in the same file), I'm not sure if there's another scenario where this could be useful ?

lcharette avatar Dec 11 '17 14:12 lcharette

Note to self, setting the db to be used can be done during the app life cycle : https://github.com/userfrosting/UserFrosting/blob/develop/app/sprinkles/core/src/Bakery/MigrateCommand.php#L96

lcharette avatar May 26 '18 20:05 lcharette

This is done in UF5 : https://github.com/userfrosting/sprinkle-core/blob/5.0/app/config/default.php#L121

lcharette avatar Nov 25 '23 02:11 lcharette