function _drush_sql_create

6.x sql.drush.inc _drush_sql_create($db_spec)
5.x sql.drush.inc _drush_sql_create($db_spec)

Generate CREATE DATABASE sql plus additonal preparations.

NOTE: sqlite needs a correct path for creating it's database file.

Parameters

type $db_spec:

Return value

type

2 calls to _drush_sql_create()
drush_sql_create in commands/sql/sql.drush.inc
Command callback. Create a database.
drush_sql_empty_db in commands/sql/sql.drush.inc
Drop all tables (if DB exists) or CREATE target database.

File

commands/sql/sql.drush.inc, line 372
Drush sql commands

Code

function _drush_sql_create($db_spec) {
  $sql = drush_sql_build_createdb_sql($db_spec, TRUE);
  if ($db_spec['driver'] == 'sqlite') {
    // Make sure sqlite can create file
    $file = $db_spec['database'];
    $path = dirname($file);
    drush_log("SQLITE: creating '$path' for creating '$file'", 'debug');
    drush_mkdir($path);
    if (!file_exists($path)) {
      drush_log("SQLITE: Cannot create $path", 'error');
    }
  }
  // Get credentials to connect to the server, but not the database which we
  // are about to DROP. @see _drush_sql_get_credentials().
  $create_db_spec = $db_spec;
  unset($create_db_spec['database']);
  $create_db_su = drush_sql_su($create_db_spec);
  return _drush_sql_query($sql, $create_db_su);
}