function migrateConfig (ipfsd) {
  // Bump revision number when new migration rule is added
  const REVISION = 6
  const REVISION_KEY = 'daemonConfigRevision'
  const CURRENT_REVISION = store.get(REVISION_KEY, 0)

  // Migration is applied only once per revision
  if (CURRENT_REVISION >= REVISION) return

  // Read config
  let config = null
  let changed = false
  try {
    config = readConfigFile(ipfsd)
  } catch (err) {
    // This is a best effort check, dont blow up here, that should happen else where.
    logger.error(`[daemon] migrateConfig: error reading config file: ${err.message || err}`)
    return
  }

  if (CURRENT_REVISION < 1) {
    // Cleanup https://github.com/ipfs-shipyard/ipfs-desktop/issues/1631
    if (config.Discovery && config.Discovery.MDNS && config.Discovery.MDNS.enabled) {
      config.Discovery.MDNS.Enabled = config.Discovery.MDNS.Enabled || true
      delete config.Discovery.MDNS.enabled
      changed = true
    }
  }

  if (CURRENT_REVISION < 3) {
    const api = config.API || {}
    const httpHeaders = api.HTTPHeaders || {}
    const accessControlAllowOrigin = httpHeaders['Access-Control-Allow-Origin'] || []

    const addURL = url => {
      if (!accessControlAllowOrigin.includes(url)) {
        accessControlAllowOrigin.push(url)
        return true
      }
      return false
    }

    const addedWebUI = addURL('https://webui.ipfs.io')
    const addedGw = addURL(`http://webui.ipfs.io.ipns.localhost:${getGatewayPort(config)}`)

    if (addedWebUI || addedGw) {
      httpHeaders['Access-Control-Allow-Origin'] = accessControlAllowOrigin
      api.HTTPHeaders = httpHeaders
      config.API = api
      changed = true
    }
  }

  if (CURRENT_REVISION < 4) {
    if (config.Swarm && config.Swarm.ConnMgr) {
      // lower ConnMgr https://github.com/ipfs/ipfs-desktop/issues/2039
      const { GracePeriod, LowWater, HighWater } = config.Swarm.ConnMgr
      if (GracePeriod === '300s') {
        config.Swarm.ConnMgr.GracePeriod = '1m'
        changed = true
      }
      if (LowWater > 20) {
        config.Swarm.ConnMgr.LowWater = 20
        changed = true
      }
      if (HighWater > 40) {
        config.Swarm.ConnMgr.HighWater = 40
        changed = true
      }
    }
  }

  if (CURRENT_REVISION < 5) {
    if (config.Swarm && config.Swarm.ConnMgr) {
      const { GracePeriod, LowWater, HighWater } = config.Swarm.ConnMgr
      // Only touch config if user runs old defaults hardcoded in ipfs-desktop
      if (GracePeriod === '1m' && LowWater === 20 && HighWater === 40) {
        config.Swarm.ConnMgr = {} // remove overrides, use defaults from Kubo https://github.com/ipfs/kubo/pull/9483
        changed = true
      }
    }
  }

  if (CURRENT_REVISION < 6) {
    // Enable AutoTLS if there is no explicit user preference
    if (config.AutoTLS === undefined) {
      config.AutoTLS = {}
      changed = true
    }
    if (config.AutoTLS.Enabled === undefined) {
      config.AutoTLS.Enabled = true
      changed = true
    }
  }

  if (changed) {
    try {
      writeConfigFile(ipfsd, config)
      store.safeSet(REVISION_KEY, REVISION)
    } catch (err) {
      logger.error(`[daemon] migrateConfig: error writing config file: ${err.message || err}`)
      return
    }
  }
  store.safeSet(REVISION_KEY, REVISION)
}
Apply one-time updates to the config of IPFS node. This is the place
where we execute fixes and performance tweaks for existing users.

@param {import('ipfsd-ctl').Controller} ipfsd