protected function reconnect($key, $database)
    {
        $connections = DB::getConnections();
        /** @var MySqlConnection $connection */
        $connection = isset($connections[$key]) ? $connections[$key] : '';

        if (is_object($connection) && $connection->getDatabaseName() != $database) {
            $connection->setDatabaseName($database);
            $connection->reconnect();
        }
    }