Exemplo n.º 1
0
/**
 * Standard table creation options
 * Array key is the ADOdb datadict driver's name
 */
$t_table_options = array('mysql' => 'DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS');
# Special handling for Oracle (oci8):
# - Field cannot be null with oci because empty string equals NULL
# - Oci uses a different date literal syntax
# - Default BLOBs to empty_blob() function
if (db_is_oracle()) {
    $t_notnull = '';
    $t_timestamp = 'timestamp' . installer_db_now();
    $t_blob_default = 'DEFAULT " empty_blob() "';
} else {
    $t_notnull = 'NOTNULL';
    $t_timestamp = '\'' . installer_db_now() . '\'';
    $t_blob_default = '';
}
/**
 * Begin schema definition
 */
$g_upgrade[0] = array('CreateTableSQL', array(db_get_table('config'), "\n\tconfig_id\t\t\t\tC(64)\tNOTNULL PRIMARY,\n\tproject_id\t\t\t\tI\t\tDEFAULT '0' PRIMARY,\n\tuser_id\t\t\t\t\tI\t\tDEFAULT '0' PRIMARY,\n\taccess_reqd\t\t\t\tI\t\tDEFAULT '0',\n\ttype\t\t\t\t\tI\t\tDEFAULT '90',\n\tvalue\t\t\t\t\tXL\t\tNOTNULL", $t_table_options));
$g_upgrade[1] = array('CreateIndexSQL', array('idx_config', db_get_table('config'), 'config_id'));
$g_upgrade[2] = array('CreateTableSQL', array(db_get_table('bug_file'), "\n\tid\t\t\t\t\t\tI\t\tUNSIGNED NOTNULL PRIMARY AUTOINCREMENT,\n\tbug_id\t\t\t\t\tI\t\tUNSIGNED NOTNULL DEFAULT '0',\n\ttitle\t\t\t\t\tC(250)\tNOTNULL DEFAULT \" '' \",\n\tdescription\t\t\t\tC(250)\tNOTNULL DEFAULT \" '' \",\n\tdiskfile\t\t\t\tC(250)\tNOTNULL DEFAULT \" '' \",\n\tfilename\t\t\t\tC(250)\tNOTNULL DEFAULT \" '' \",\n\tfolder\t\t\t\t\tC(250)\tNOTNULL DEFAULT \" '' \",\n\tfilesize\t\t\t\tI\t\tNOTNULL DEFAULT '0',\n\tfile_type\t\t\t\tC(250)\tNOTNULL DEFAULT \" '' \",\n\tdate_added\t\t\t\tT\t\tNOTNULL DEFAULT '" . db_null_date() . "',\n\tcontent\t\t\t\t\tB\t\tNOTNULL " . $t_blob_default, $t_table_options));
$g_upgrade[3] = array('CreateIndexSQL', array('idx_bug_file_bug_id', db_get_table('bug_file'), 'bug_id'));
$g_upgrade[4] = array('CreateTableSQL', array(db_get_table('bug_history'), "\n\tid\t\t\t\t\t\tI\t\tUNSIGNED NOTNULL PRIMARY AUTOINCREMENT,\n\tuser_id\t\t\t\t\tI\t\tUNSIGNED NOTNULL DEFAULT '0',\n\tbug_id\t\t\t\t\tI\t\tUNSIGNED NOTNULL DEFAULT '0',\n\tdate_modified\t\t\tT\t\tNOTNULL DEFAULT '" . db_null_date() . "',\n\tfield_name\t\t\t\tC(32)\t{$t_notnull} DEFAULT \" '' \",\n\told_value\t\t\t\tC(128)\t{$t_notnull} DEFAULT \" '' \",\n\tnew_value\t\t\t\tC(128)\t{$t_notnull} DEFAULT \" '' \",\n\ttype\t\t\t\t\tI2\t\tNOTNULL DEFAULT '0'", $t_table_options));
$g_upgrade[5] = array('CreateIndexSQL', array('idx_bug_history_bug_id', db_get_table('bug_history'), 'bug_id'));
$g_upgrade[6] = array('CreateIndexSQL', array('idx_history_user_id', db_get_table('bug_history'), 'user_id'));
$g_upgrade[7] = array('CreateTableSQL', array(db_get_table('bug_monitor'), "\n\tuser_id\t\t\t\t\tI\t\tUNSIGNED NOTNULL PRIMARY DEFAULT '0',\n\tbug_id\t\t\t\t\tI\t\tUNSIGNED NOTNULL PRIMARY DEFAULT '0'\n\t", $t_table_options));
$g_upgrade[8] = array('CreateTableSQL', array(db_get_table('bug_relationship'), "\n\tid\t\t\t\t\t\tI\t\tUNSIGNED NOTNULL AUTOINCREMENT PRIMARY,\n\tsource_bug_id\t\t\tI\t\tUNSIGNED NOTNULL DEFAULT '0',\n\tdestination_bug_id\t\tI\t\tUNSIGNED NOTNULL DEFAULT '0',\n\trelationship_type\t\tI2\t\tNOTNULL DEFAULT '0' ", $t_table_options));
$g_upgrade[9] = array('CreateIndexSQL', array('idx_relationship_source', db_get_table('bug_relationship'), 'source_bug_id'));
Exemplo n.º 2
0
$upgrade[] = array('CreateIndexSQL', array('idx_project_version', db_get_table('project_version'), 'project_id,version', array('UNIQUE')));
$upgrade[] = array('CreateTableSQL', array(db_get_table('sponsorship'), "\n  id \t\t\t I  NOTNULL PRIMARY AUTOINCREMENT,\n  bug_id \t\t I  NOTNULL DEFAULT '0',\n  user_id \t\t I  NOTNULL DEFAULT '0',\n  amount \t\t I  NOTNULL DEFAULT '0',\n  logo \t\t\tC(128) NOTNULL DEFAULT \" '' \",\n  url \t\t\tC(128) NOTNULL DEFAULT \" '' \",\n  paid \t\t\tL NOTNULL DEFAULT \" '0' \",\n  date_submitted \tT NOTNULL DEFAULT '" . db_null_date() . "',\n  last_updated \t\tT NOTNULL DEFAULT '" . db_null_date() . "'\n", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
/* 40 */
$upgrade[] = array('CreateIndexSQL', array('idx_sponsorship_bug_id', db_get_table('sponsorship'), 'bug_id'));
$upgrade[] = array('CreateIndexSQL', array('idx_sponsorship_user_id', db_get_table('sponsorship'), 'user_id'));
$upgrade[] = array('CreateTableSQL', array(db_get_table('tokens'), "\n\t\t\t  id I NOTNULL PRIMARY AUTOINCREMENT,\n\t\t\t  owner I NOTNULL,\n\t\t\t  type I NOTNULL,\n\t\t\t  timestamp T NOTNULL,\n\t\t\t  expiry T,\n\t\t\t  value XL NOTNULL", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = array('CreateTableSQL', array(db_get_table('user_pref'), "\n  id \t\t\t I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,\n  user_id \t\t I  UNSIGNED NOTNULL DEFAULT '0',\n  project_id \t\t I  UNSIGNED NOTNULL DEFAULT '0',\n  default_profile \t I  UNSIGNED NOTNULL DEFAULT '0',\n  default_project \t I  UNSIGNED NOTNULL DEFAULT '0',\n  advanced_report \tL NOTNULL DEFAULT \" '0' \",\n  advanced_view \tL NOTNULL DEFAULT \" '0' \",\n  advanced_update \tL NOTNULL DEFAULT \" '0' \",\n  refresh_delay \t I  NOTNULL DEFAULT '0',\n  redirect_delay \tL NOTNULL DEFAULT \" '0' \",\n  bugnote_order \tC(4) NOTNULL DEFAULT 'ASC',\n  email_on_new \t\tL NOTNULL DEFAULT \" '0' \",\n  email_on_assigned \tL NOTNULL DEFAULT \" '0' \",\n  email_on_feedback \tL NOTNULL DEFAULT \" '0' \",\n  email_on_resolved\tL NOTNULL DEFAULT \" '0' \",\n  email_on_closed \tL NOTNULL DEFAULT \" '0' \",\n  email_on_reopened \tL NOTNULL DEFAULT \" '0' \",\n  email_on_bugnote \tL NOTNULL DEFAULT \" '0' \",\n  email_on_status \tL NOTNULL DEFAULT \" '0' \",\n  email_on_priority \tL NOTNULL DEFAULT \" '0' \",\n  email_on_priority_min_severity \tI2 NOTNULL DEFAULT '10',\n  email_on_status_min_severity \tI2 NOTNULL DEFAULT '10',\n  email_on_bugnote_min_severity \tI2 NOTNULL DEFAULT '10',\n  email_on_reopened_min_severity \tI2 NOTNULL DEFAULT '10',\n  email_on_closed_min_severity \tI2 NOTNULL DEFAULT '10',\n  email_on_resolved_min_severity \tI2 NOTNULL DEFAULT '10',\n  email_on_feedback_min_severity\tI2 NOTNULL DEFAULT '10',\n  email_on_assigned_min_severity \tI2 NOTNULL DEFAULT '10',\n  email_on_new_min_severity \tI2 NOTNULL DEFAULT '10',\n  email_bugnote_limit \tI2 NOTNULL DEFAULT '0',\n  language \t\tC(32) NOTNULL DEFAULT 'english'\n", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = array('CreateTableSQL', array(db_get_table('user_print_pref'), "\n  user_id \t\t I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',\n  print_pref \t\tC(27) NOTNULL DEFAULT \" '' \"\n", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = array('CreateTableSQL', array(db_get_table('user_profile'), "\n  id \t\t\t I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,\n  user_id \t\t I  UNSIGNED NOTNULL DEFAULT '0',\n  platform \t\tC(32) NOTNULL DEFAULT \" '' \",\n  os \t\t\tC(32) NOTNULL DEFAULT \" '' \",\n  os_build \t\tC(32) NOTNULL DEFAULT \" '' \",\n  description \t\tXL NOTNULL\n", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = array('CreateTableSQL', array(db_get_table('user'), "\n  id \t\t\t I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,\n  username \t\tC(32) NOTNULL DEFAULT \" '' \",\n  realname \t\tC(64) NOTNULL DEFAULT \" '' \",\n  email \t\tC(64) NOTNULL DEFAULT \" '' \",\n  password \t\tC(32) NOTNULL DEFAULT \" '' \",\n  date_created \t\tT NOTNULL DEFAULT '" . db_null_date() . "',\n  last_visit \t\tT NOTNULL DEFAULT '" . db_null_date() . "',\n  enabled\t\tL NOTNULL DEFAULT \" '1' \",\n  protected \t\tL NOTNULL DEFAULT \" '0' \",\n  access_level \t\tI2 NOTNULL DEFAULT '10',\n  login_count \t\t I  NOTNULL DEFAULT '0',\n  lost_password_request_count \tI2 NOTNULL DEFAULT '0',\n  failed_login_count \tI2 NOTNULL DEFAULT '0',\n  cookie_string \tC(64) NOTNULL DEFAULT \" '' \"\n", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = array('CreateIndexSQL', array('idx_user_cookie_string', db_get_table('user'), 'cookie_string', array('UNIQUE')));
$upgrade[] = array('CreateIndexSQL', array('idx_user_username', db_get_table('user'), 'username', array('UNIQUE')));
$upgrade[] = array('CreateIndexSQL', array('idx_enable', db_get_table('user'), 'enabled'));
/* 50 */
$upgrade[] = array('CreateIndexSQL', array('idx_access', db_get_table('user'), 'access_level'));
$upgrade[] = array('InsertData', array(db_get_table('user'), "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES\n        ('administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', '" . installer_db_now() . "', '" . installer_db_now() . "', '1', '0', 90, 3, 0, 0, '" . md5(mt_rand(0, mt_getrandmax()) + mt_rand(0, mt_getrandmax())) . md5(time()) . "')"));
$upgrade[] = array('AlterColumnSQL', array(db_get_table('bug_history'), "old_value C(255) NOTNULL"));
$upgrade[] = array('AlterColumnSQL', array(db_get_table('bug_history'), "new_value C(255) NOTNULL"));
$upgrade[] = array('CreateTableSQL', array(db_get_table('email'), "\n  email_id \t\tI  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,\n  email\t\t \tC(64) NOTNULL DEFAULT \" '' \",\n  subject\t\tC(250) NOTNULL DEFAULT \" '' \",\n  submitted \tT NOTNULL DEFAULT '" . db_null_date() . "',\n  metadata \t\tXL NOTNULL,\n  body \t\t\tXL NOTNULL\n  ", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = array('CreateIndexSQL', array('idx_email_id', db_get_table('email'), 'email_id'));
$upgrade[] = array('AddColumnSQL', array(db_get_table('bug'), "target_version C(64) NOTNULL DEFAULT \" '' \""));
$upgrade[] = array('AddColumnSQL', array(db_get_table('bugnote'), "time_tracking I UNSIGNED NOTNULL DEFAULT \" 0 \""));
$upgrade[] = array('CreateIndexSQL', array('idx_diskfile', db_get_table('bug_file'), 'diskfile'));
$upgrade[] = array('AlterColumnSQL', array(db_get_table('user_print_pref'), "print_pref C(64) NOTNULL"));
/* 60 */
$upgrade[] = array('AlterColumnSQL', array(db_get_table('bug_history'), "field_name C(64) NOTNULL"));
# Release marker: 1.1.0a4
$upgrade[] = array('CreateTableSQL', array(db_get_table('tag'), "\n\tid\t\t\t\tI\t\tUNSIGNED NOTNULL PRIMARY AUTOINCREMENT,\n\tuser_id\t\t\tI\t\tUNSIGNED NOTNULL DEFAULT '0',\n\tname\t\t\tC(100)\tNOTNULL PRIMARY DEFAULT \" '' \",\n\tdescription\t\tXL\t\tNOTNULL,\n\tdate_created\tT\t\tNOTNULL DEFAULT '" . db_null_date() . "',\n\tdate_updated\tT\t\tNOTNULL DEFAULT '" . db_null_date() . "'\n\t", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = array('CreateTableSQL', array(db_get_table('bug_tag'), "\n\tbug_id\t\t\tI\tUNSIGNED NOTNULL PRIMARY DEFAULT '0',\n\ttag_id\t\t\tI\tUNSIGNED NOTNULL PRIMARY DEFAULT '0',\n\tuser_id\t\t\tI\tUNSIGNED NOTNULL DEFAULT '0',\n\tdate_attached\tT\tNOTNULL DEFAULT '" . db_null_date() . "'\n\t", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = array('CreateIndexSQL', array('idx_typeowner', db_get_table('tokens'), 'type, owner'));
# Release marker: 1.2.0-SVN
Exemplo n.º 3
0
function installer_db_now()
{
    global $g_db;
    return $g_db->BindTimeStamp(time());
}
# Special handling for Oracle (oci8):
# - Field cannot be null with oci because empty string equals NULL
# - Oci uses a different date literal syntax
# - Default BLOBs to empty_blob() function
if (db_is_oracle()) {
    $t_notnull = "";
    $t_timestamp = "timestamp" . installer_db_now();
    $t_blob_default = 'DEFAULT " empty_blob() "';
} else {
    $t_notnull = 'NOTNULL';
    $t_timestamp = "'" . installer_db_now() . "'";
    $t_blob_default = '';
}
/**
 * Begin schema definition
 *
 * 'Release markers' are placed right AFTER the last schema step that is
 * included in the corresponding release
 */
$upgrade[0] = array('CreateTableSQL', array(db_get_table('config'), "\n\t\t\t  config_id C(64) NOTNULL PRIMARY,\n\t\t\t  project_id I DEFAULT '0' PRIMARY,\n\t\t\t  user_id I DEFAULT '0' PRIMARY,\n\t\t\t  access_reqd I DEFAULT '0',\n\t\t\t  type I DEFAULT '90',\n\t\t\t  value XL NOTNULL", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[1] = array('CreateIndexSQL', array('idx_config', db_get_table('config'), 'config_id'));
$upgrade[2] = array('CreateTableSQL', array(db_get_table('bug_file'), "\n  id\t\t\t I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,\n  bug_id \t\t I  UNSIGNED NOTNULL DEFAULT '0',\n  title \t\tC(250) NOTNULL DEFAULT \" '' \",\n  description \t\tC(250) NOTNULL DEFAULT \" '' \",\n  diskfile \t\tC(250) NOTNULL DEFAULT \" '' \",\n  filename \t\tC(250) NOTNULL DEFAULT \" '' \",\n  folder \t\tC(250) NOTNULL DEFAULT \" '' \",\n  filesize \t\t I NOTNULL DEFAULT '0',\n  file_type \t\tC(250) NOTNULL DEFAULT \" '' \",\n  date_added \t\tT NOTNULL DEFAULT '" . db_null_date() . "',\n  content \t\tB NOTNULL {$t_blob_default}\n  ", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[3] = array('CreateIndexSQL', array('idx_bug_file_bug_id', db_get_table('bug_file'), 'bug_id'));
$upgrade[4] = array('CreateTableSQL', array(db_get_table('bug_history'), "\n  id \t\t\t I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,\n  user_id \t\t I  UNSIGNED NOTNULL DEFAULT '0',\n  bug_id \t\t I  UNSIGNED NOTNULL DEFAULT '0',\n  date_modified \tT NOTNULL DEFAULT '" . db_null_date() . "',\n  field_name \t\tC(32) {$t_notnull} DEFAULT \" '' \",\n  old_value \t\tC(128) {$t_notnull} DEFAULT \" '' \",\n  new_value \t\tC(128) {$t_notnull} DEFAULT \" '' \",\n  type \t\t\tI2 NOTNULL DEFAULT '0'\n  ", array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[5] = array('CreateIndexSQL', array('idx_bug_history_bug_id', db_get_table('bug_history'), 'bug_id'));
$upgrade[6] = array('CreateIndexSQL', array('idx_history_user_id', db_get_table('bug_history'), 'user_id'));