Commit df3a5fb1 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Hack for Mysql/XMLDB upgrade problem (bug #3046)

parent 8f7b65ba
......@@ -1425,17 +1425,29 @@ function xmldb_core_upgrade($oldversion=0) {
if ($oldversion < 2008102400) {
// Feedback can be left by anon users with a view token, so feedback author must be nullable
$table = new XMLDBTable('view_feedback');
$field = new XMLDBField('author');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED);
change_field_notnull($table, $field);
if (is_mysql()) {
execute_sql("ALTER TABLE {view_feedback} DROP FOREIGN KEY viewfeed_aut_fk");
execute_sql('ALTER TABLE {view_feedback} MODIFY author BIGINT(10) NULL');
}
else {
$field = new XMLDBField('author');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED);
change_field_notnull($table, $field);
}
$key = new XMLDBKEY('authorfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('author'), 'usr', array('id'));
add_key($table, $key);
$table = new XMLDBTable('artefact_feedback');
$field = new XMLDBField('author');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED);
change_field_notnull($table, $field);
if (is_mysql()) {
execute_sql("ALTER TABLE {artefact_feedback} DROP FOREIGN KEY artefeed_aut_fk");
execute_sql('ALTER TABLE {artefact_feedback} MODIFY author BIGINT(10) NULL');
}
else {
$field = new XMLDBField('author');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED);
change_field_notnull($table, $field);
}
$key = new XMLDBKEY('authorfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('author'), 'usr', array('id'));
add_key($table, $key);
......
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