protected function resolveDatabaseServiceInstance($service = null)
    {
        /** @var EngineType $engine */
        $engine = $this->getEngineInstance();
        $services = $engine->getServiceInstanceByGroup('database');

        if (!isset($service) || !isset($services[$service])) {
            if (count($services) > 1) {
                $options = array_keys($services);
                $service = $this->doAsk(
                    new ChoiceQuestion(
                        'Select the database service to use for import: ',
                        $options
                    )
                );
            } else {
                $options = array_keys($services);
                $service = reset($options);
            }
        }

        if (!isset($services[$service])) {
            throw new \RuntimeException(
                'Unable to resolve database service.'
            );
        }

        return $services[$service];
    }