UserFrosting
UserFrosting copied to clipboard
Config for default database connection to use
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 ?
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
This is done in UF5 : https://github.com/userfrosting/sprinkle-core/blob/5.0/app/config/default.php#L121