initMaster = async ({ disableMigrate }, useClusterAdaptor = true) => {
  let sql_log;
  try {
    sql_log = await getConfig("log_sql");
  } catch (e) {
    const msg = e.message;
    if (msg && msg.includes("_sc_config"))
      console.error(
        "Database is reachable but not initialised. Please run 'saltcorn reset-schema' or 'saltcorn add-schema'"
      );
    else {
      console.error("Database is not reachable. The error was: ", msg);
      console.error("Connection parameters tried: ");
      console.error(db.connectObj);
    }
    process.exit(1);
  }
  // switch on sql logging
  if (sql_log) db.set_sql_logging(); // dont override cli flag
  // migrate database
  if (!disableMigrate)
    await db.runWithTenant(
      db.connectObj.default_schema,
      async () => await migrate(db.connectObj.default_schema, true)
    );
  // load all plugins
  await loadAllPlugins(true);
  // switch on sql logging - but it was initiated before???
  if (getState().getConfig("log_sql", false)) db.set_sql_logging();
  if (db.is_it_multi_tenant()) {
    const tenants = await getAllTenants();
    await init_multi_tenant(loadAllPlugins, disableMigrate, tenants);
  }
  eachTenant(async () => {
    const state = getState();
    if (state) {
      await state.setConfig("joined_log_socket_ids", []);
      await state.setConfig("joined_real_time_socket_ids", []);
    }
  });
  if (useClusterAdaptor) setupPrimary();
}
@param {object} opts
@param {boolean} opts.disableMigrate
@param {boolean} [useClusterAdaptor = true]