errno_t sssctl_cache_upgrade(struct sss_cmdline *cmdline,
                             struct sss_tool_ctx *tool_ctx,
                             void *pvt)
{
    struct sysdb_upgrade_ctx db_up_ctx;
    errno_t ret;

    ret = sss_tool_popt(cmdline, NULL, SSS_TOOL_OPT_OPTIONAL, NULL, NULL);
    if (ret != EOK) {
        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to parse command arguments\n");
        return ret;
    }

    if (sss_daemon_running()) {
        return ERR_SSSD_RUNNING;
    }

    ret = confdb_get_domains(tool_ctx->confdb, &tool_ctx->domains);
    if (ret != EOK) {
        DEBUG(SSSDBG_FATAL_FAILURE, "No domains configured.\n");
        return ret;
    }

    db_up_ctx.cdb = tool_ctx->confdb;
    ret = sysdb_init_ext(tool_ctx, tool_ctx->domains, &db_up_ctx,
                         true, 0, 0);
    if (ret != EOK) {
        SYSDB_VERSION_ERROR_DAEMON(ret);
        return ret;
    }

    return EOK;
}
errno_t sssctl_cache_upgrade(struct sss_cmdline *cmdline,
                             struct sss_tool_ctx *tool_ctx,
                             void *pvt)
{
    struct sysdb_upgrade_ctx db_up_ctx;
    errno_t ret;

    ret = sss_tool_popt(cmdline, NULL, SSS_TOOL_OPT_OPTIONAL, NULL, NULL);
    if (ret != EOK) {
        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to parse command arguments\n");
        return ret;
    }

    if (sss_daemon_running()) {
        return ERR_SSSD_RUNNING;
    }

    ret = confdb_get_domains(tool_ctx->confdb, &tool_ctx->domains);
    if (ret != EOK) {
        DEBUG(SSSDBG_FATAL_FAILURE, "No domains configured.\n");
        return ret;
    }

    db_up_ctx.cdb = tool_ctx->confdb;
    ret = sysdb_init_ext(tool_ctx, tool_ctx->domains, &db_up_ctx,
                         true, 0, 0);
    if (ret != EOK) {
        SYSDB_VERSION_ERROR_DAEMON(ret);
        return ret;
    }

    return EOK;
}