I am using the knex library (https://www.npmjs.com/package/knex) for NodeJS and MySQL and I would like to implement a fallback database connection in case that the current database is not reachable anymore.
I ve read that via the knex config it is possible to use for example the config options "ping" (https://github.com/knex/knex/issues/1198#issuecomment-185310131) and "afterCreate" (https://github.com/knex/documentation/pull/17/files) to detect if it is not possible anymore to connect to the database.
But in case it is not possible how exactly can i overwrite the existing connection settings, establish a new database connection and make it available to all upcoming queries within these config options?