Commit 5791e3f9 authored by Nigel McNie's avatar Nigel McNie
Browse files

Re-fix the postgres upgrade to work properly after the mysql fixes were applied.

parent 3a95dff3
...@@ -31,6 +31,12 @@ function xmldb_artefact_resume_upgrade($oldversion=0) { ...@@ -31,6 +31,12 @@ function xmldb_artefact_resume_upgrade($oldversion=0) {
$status = true; $status = true;
if ($oldversion < 2008012200) { if ($oldversion < 2008012200) {
if (is_mysql()) {
$inttype = 'BIGINT(10)';
}
else {
$inttype = 'INTEGER';
}
foreach (array( foreach (array(
'artefact_resume_employmenthistory', 'artefact_resume_employmenthistory',
'artefact_resume_educationhistory', 'artefact_resume_educationhistory',
...@@ -39,7 +45,7 @@ function xmldb_artefact_resume_upgrade($oldversion=0) { ...@@ -39,7 +45,7 @@ function xmldb_artefact_resume_upgrade($oldversion=0) {
// Sigh. table_column is screwed beyond belief. We let it do its // Sigh. table_column is screwed beyond belief. We let it do its
// work (in the case of start and stopdate at least because it does // work (in the case of start and stopdate at least because it does
// cast the columns OK), then fix its bugs // cast the columns OK), then fix its bugs
execute_sql('ALTER TABLE {' . $table . '} ADD displayorder BIGINT(10)'); execute_sql('ALTER TABLE {' . $table . '} ADD displayorder ' . $inttype);
table_column($table, 'startdate', 'startdate', 'text', null, null, '', 'not null'); table_column($table, 'startdate', 'startdate', 'text', null, null, '', 'not null');
table_column($table, 'enddate', 'enddate', 'text', null, null, '', ''); table_column($table, 'enddate', 'enddate', 'text', null, null, '', '');
...@@ -66,19 +72,19 @@ function xmldb_artefact_resume_upgrade($oldversion=0) { ...@@ -66,19 +72,19 @@ function xmldb_artefact_resume_upgrade($oldversion=0) {
} }
} }
if (is_mysql()) { if (is_mysql()) {
execute_sql('ALTER TABLE {' . $table .'} MODIFY displayorder BIGINT(10) NOT NULL'); execute_sql('ALTER TABLE {' . $table .'} MODIFY displayorder ' . $inttype . ' NOT NULL');
//execute_sql('ALTER TABLE {' . $table .'} MODIFY startdate TEXT NOT NULL'); execute_sql('ALTER TABLE {' . $table .'} MODIFY startdate TEXT NOT NULL');
} }
else { else {
execute_sql('ALTER TABLE {' . $table . '} ALTER displayorder SET NOT NULL'); execute_sql('ALTER TABLE {' . $table . '} ALTER displayorder SET NOT NULL');
//execute_sql('ALTER TABLE {' . $table . '} ALTER COLUMN startdate SET NOT NULL'); execute_sql('ALTER TABLE {' . $table . '} ALTER COLUMN startdate SET NOT NULL');
} }
} }
foreach (array( foreach (array(
'artefact_resume_certification', 'artefact_resume_certification',
'artefact_resume_book') as $table) { 'artefact_resume_book') as $table) {
$records = get_records_array($table, '', '', 'date DESC', 'id,date'); $records = get_records_array($table, '', '', 'date DESC', 'id,date');
execute_sql('ALTER TABLE {' . $table . '} ADD displayorder BIGINT(10)'); execute_sql('ALTER TABLE {' . $table . '} ADD displayorder ' . $inttype);
table_column($table, 'date', 'date', 'text', null, null, '', 'not null'); table_column($table, 'date', 'date', 'text', null, null, '', 'not null');
if (is_postgres()) { if (is_postgres()) {
execute_sql('ALTER TABLE {' . $table . '} ALTER COLUMN date DROP DEFAULT'); execute_sql('ALTER TABLE {' . $table . '} ALTER COLUMN date DROP DEFAULT');
...@@ -92,12 +98,12 @@ function xmldb_artefact_resume_upgrade($oldversion=0) { ...@@ -92,12 +98,12 @@ function xmldb_artefact_resume_upgrade($oldversion=0) {
} }
} }
if (is_mysql()) { if (is_mysql()) {
execute_sql('ALTER TABLE {' . $table . '} MODIFY displayorder BIGINT(10) NOT NULL'); execute_sql('ALTER TABLE {' . $table . '} MODIFY displayorder ' . $inttype . ' NOT NULL');
} }
else { else {
execute_sql('ALTER TABLE {' . $table . '} ALTER displayorder SET NOT NULL'); execute_sql('ALTER TABLE {' . $table . '} ALTER displayorder SET NOT NULL');
execute_sql('ALTER TABLE {' . $table . '} ALTER COLUMN date SET NOT NULL');
} }
//execute_sql('ALTER TABLE {' . $table . '} ALTER COLUMN date SET NOT NULL');
} }
} }
......
...@@ -796,8 +796,15 @@ function xmldb_core_upgrade($oldversion=0) { ...@@ -796,8 +796,15 @@ function xmldb_core_upgrade($oldversion=0) {
// New columns for institution table // New columns for institution table
execute_sql('ALTER TABLE {institution} ADD COLUMN theme varchar(255)'); execute_sql('ALTER TABLE {institution} ADD COLUMN theme varchar(255)');
set_field('institution', 'theme', get_config('theme')); set_field('institution', 'theme', get_config('theme'));
execute_sql('ALTER TABLE {institution} ADD COLUMN defaultmembershipperiod BIGINT(10)');
execute_sql('ALTER TABLE {institution} ADD COLUMN maxuseraccounts BIGINT(10)'); if (is_mysql()) {
$type = 'BIGINT(10)';
}
else {
$type = 'INTEGER';
}
execute_sql('ALTER TABLE {institution} ADD COLUMN defaultmembershipperiod ' . $type);
execute_sql('ALTER TABLE {institution} ADD COLUMN maxuseraccounts ' . $type);
} }
......
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