Commit a8efe6f5 authored by Penny Leach's avatar Penny Leach
Browse files

changed the community schema.

changed the installer to deal nicer with in-place upgrades.
brought back required function in dml (column_type)
all db upgrades should now happen in-place.
this means changing BOTH install.xml AND upgrade.php
parent 0a19f13a
......@@ -72,19 +72,20 @@ if (!empty($upgrade)) {
}
try {
$funname($upgrade);
$data['success'] = 1;
$data['install'] = $upgrade->install;
if (isset($upgrade->install)) {
$data['install'] = $upgrade->install;
}
json_reply(false, $data);
exit;
}
catch (Exception $e) {
$data['errormessage'] = $e->getMessage();
$data['success'] = 0;
json_reply(true, $data);
exit;
}
}
else {
$data['success'] = 1;
$data['errormessage'] = get_string('nothingtoupgrade','admin');
json_reply(false, array('message' => string('nothingtoupgrade','admin')));
exit;
}
// @todo json_reply?
echo json_encode($data);
?>
......@@ -104,24 +104,24 @@ $js .= <<< EOJS
d.addCallbacks(function (data) {
if ( !data.error ) {
var message;
if (data.install) {
if (data.message.install) {
message = '{$installsuccessstring}';
}
else {
message = '{$successstring}';
}
message += data.newversion;
$(data.key).innerHTML = '<img src="{$successicon}" alt=":)" /> ' + message;
message += data.message.newversion;
$(data.message.key).innerHTML = '<img src="{$successicon}" alt=":)" /> ' + message;
}
else {
var message = '';
if (data.message) {
message = data.message;
if (data.message.errormessage) {
message = data.message.errormessage;
}
else {
message = '{$failurestring}';
}
$(data.key).innerHTML = '<img src="{$failureicon}" alt=":(" /> ' + message;
$(data.message.key).innerHTML = '<img src="{$failureicon}" alt=":(" /> ' + message;
}
processNext();
}, function () {
......
......@@ -374,7 +374,7 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="name" TYPE="text" NOTNULL="true" />
<FIELD NAME="description" TYPE="text" NOTNULL="false" />
<FIELD NAME="jointype" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="anyone" />
<FIELD NAME="jointype" TYPE="char" LENGTH="20" NOTNULL="true" ENUM="true" ENUMVALUES="'controlled', 'invite', 'request', 'open'" DEFAULT="open" />
<FIELD NAME="owner" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="ctime" TYPE="datetime" NOTNULL="true" />
<FIELD NAME="mtime" TYPE="datetime" NOTNULL="true" />
......
......@@ -30,7 +30,16 @@ function xmldb_core_upgrade($oldversion=0) {
$status = true;
// Upgrades later :)
if ($oldversion < 2006121400) {
set_field('community', 'jointype', 'open', 'jointype', 'anyone');
$table = new XMLDBTable('community');
$field = new XMLDBField('jointype');
$field->setAttributes(XMLDB_TYPE_CHAR, 20, false, true, false, true,
array('controlled', 'invite', 'request', 'open'), 'open');
change_field_default($table, $field);
change_field_enum($table, $field);
}
return $status;
......
......@@ -1141,8 +1141,6 @@ function where_values_prepared($value1=null, $value2=null, $value3=null, $value4
* @param string $column The name of the field in the table
* @return string Field type or false if error
*/
// NOTE: commented out until a good reason is found for it. The implemenation looks shoddy at best anyway...
/*
function column_type($table, $column) {
global $db;
......@@ -1153,7 +1151,6 @@ function column_type($table, $column) {
$field = $rs->FetchField(0);
return $rs->MetaType($field->type);
}
*/
/**
* This function will execute an array of SQL commands, returning
......
......@@ -172,33 +172,28 @@ function upgrade_core($upgrade) {
global $db;
$location = get_config('libroot') . '/db/';
$db->StartTrans();
db_begin();
if (!empty($upgrade->install)) {
$status = install_from_xmldb_file($location . 'install.xml');
if (!install_from_xmldb_file($location . 'install.xml')) {
throw new SQLException("Failed to upgrade core (check logs)");
}
}
else {
require_once($location . 'upgrade.php');
$status = xmldb_core_upgrade($upgrade->from);
}
if (!$status) {
throw new SQLException("Failed to upgrade core");
xmldb_core_upgrade($upgrade->from);
}
$status = set_config('version', $upgrade->to);
$status = $status && set_config('release', $upgrade->torelease);
if ($db->HasFailedTrans()) {
$status = false;
}
set_config('version', $upgrade->to);
set_config('release', $upgrade->torelease);
if (!empty($upgrade->install)) {
$status = $status && core_postinst();
core_postinst();
}
$db->CompleteTrans();
return $status;
db_commit();
return true;
}
/**
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2006102000;
$config->version = 2006121400;
$config->release = '0.1';
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment