lib/sailsDbMigrate.js
function parseSailsConfig(sailsConfig) {
  var res = {};
  var connection;

  if (!sailsConfig.migrations) {
    throw new Error('Migrations not configured. Please setup ./config/migrations.js');
  }

  var connectionName = sailsConfig.migrations.connection;
  if (!connectionName) {
    throw new Error('connection missing from ./config/migrations.js');
  }

  connection = sailsConfig.connections[connectionName];

  if (!connection) {
    throw new Error('could not find connection ' + connectionName + ' in ./config/connections.js');
  }

  // build the db url, which contains the password
  res.url = buildURL(connection);
  // check for ssl option in connection config
  if (connection.ssl) {
    res.adapter = connection.adapter;
    res.ssl = true;
  }
  // now build a clean one for logging, without the password
  if (connection.password != null) {
    connection.password = '****';
  }
  res.cleanURL = buildURL(connection);

  return res;
}
function parseSailsConfig(sailsConfig) {
  var res = {};
  var connection;

  if (!sailsConfig.migrations) {
    throw new Error('Migrations not configured. Please setup ./config/migrations.js');
  }

  var connectionName = sailsConfig.migrations.connection;
  if (!connectionName) {
    throw new Error('connection missing from ./config/migrations.js');
  }

  connection = sailsConfig.connections[connectionName];

  if (!connection) {
    throw new Error('could not find connection ' + connectionName + ' in ./config/connections.js');
  }

  // build the db url, which contains the password
  res.url = buildURL(connection);
  // check for ssl option in connection config
  if (connection.ssl) {
    res.adapter = connection.adapter;
    res.ssl = true;
  }
  // now build a clean one for logging, without the password
  if (connection.password != null) {
    connection.password = '****';
  }
  res.cleanURL = buildURL(connection);

  return res;
}
function parseSailsConfig ( sailsConfig ) { var res = { } ; var connection ; if ( ! sailsConfig . migrations ) { throw new Error ( 'Migrations not configured. Please setup ./config/migrations.js' ) ; } var connectionName = sailsConfig . migrations . connection ; if ( ! connectionName ) { throw new Error ( 'connection missing from ./config/migrations.js' ) ; } connection = sailsConfig . connections [ connectionName ] ; if ( ! connection ) { throw new Error ( 'could not find connection ' + connectionName + ' in ./config/connections.js' ) ; } // build the db url, which contains the password res . url = buildURL ( connection ) ; // check for ssl option in connection config if ( connection . ssl ) { res . adapter = connection . adapter ; res . ssl = true ; } // now build a clean one for logging, without the password if ( connection . password != null ) { connection . password = '****' ; } res . cleanURL = buildURL ( connection ) ; return res ; }
Parse out the database URL from the sails config.

@param sailsConfig Sails config object.
@returns {object} .url and .cleanURL for the database connection.
@throws Error if adapter is not supported.
Parse out the database URL from the sails config .