Permalink
Browse files

Merge from MOODLE_14_STABLE

Additional fixes for indexes in postgres. A few unique indexes may have been created non-unique. Still deferring the version bump -- please review the patch!

Merge of patchsets
 arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-423
 arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-425
  • Loading branch information...
1 parent 33bb37e commit b692d2be05ac5552a56cea1d21161bd53e48ea0e martinlanghoff committed Nov 24, 2004
Showing with 22 additions and 7 deletions.
  1. +20 −6 lib/db/postgres7.php
  2. +2 −1 lib/db/postgres7.sql
View
@@ -735,10 +735,10 @@ function main_upgrade($oldversion=0) {
}
flush();
- // drop some indexes quietly -- they may or may not exist depending on what version
- // the user upgrades from
+ // drop some indexes quietly -- they may or may not exist depending on what version
+ // the user upgrades from
execute_sql("DROP INDEX {$CFG->prefix}user_students_courseuserid_idx ", false);
- execute_sql("DROP INDEX {$CFG->prefix}user_students_courseuserid_uk ", false);
+ execute_sql("DROP INDEX {$CFG->prefix}user_students_courseuserid_uk ", false);
modify_database('','CREATE UNIQUE INDEX prefix_user_students_courseuserid_uk ON prefix_user_students (course,userid);');
/// Delete duplicate teacher enrolments
@@ -752,13 +752,27 @@ function main_upgrade($oldversion=0) {
}
flush();
- // drop some indexes quietly -- they may or may not exist depending on what version
- // the user upgrades from
+ // drop some indexes quietly -- they may or may not exist depending on what version
+ // the user upgrades from
execute_sql("DROP INDEX {$CFG->prefix}user_teachers_courseuserid_idx ", false);
- execute_sql("DROP INDEX {$CFG->prefix}user_teachers_courseuserid_uk ", false);
+ execute_sql("DROP INDEX {$CFG->prefix}user_teachers_courseuserid_uk ", false);
modify_database('','CREATE UNIQUE INDEX prefix_user_teachers_courseuserid_uk ON prefix_user_teachers (course,userid);');
}
+ if ($oldversion < 2004112401) {
+ // some postgres databases may have a non-unique index mislabeled unique.
+ fix_course_sortorder(0,0,1);
+ execute_sql("DROP INDEX {$CFG->prefix}course_category_sortorder_uk ", false);
+ execute_sql("DROP INDEX {$CFG->prefix}course_category_idx ", false);
+ modify_database('', "CREATE UNIQUE INDEX prefix_course_category_sortorder_uk ON prefix_course(category,sortorder);");
+
+ // odd! username was missing its unique index!
+ // first silently drop it just in case...
+ execute_sql("DROP INDEX {$CFG->prefix}user_username_uk", false);
+ modify_database('', "CREATE UNIQUE INDEX prefix_user_username_uk ON prefix_user (username);");
+
+ }
+
return $result;
}
View
@@ -39,7 +39,7 @@ CREATE TABLE prefix_course (
timemodified integer NOT NULL default '0'
);
-CREATE INDEX prefix_course_category_idx ON prefix_course (category);
+CREATE UNIQUE INDEX prefix_course_category_sortorder_uk ON prefix_course (category,sortorder);
CREATE INDEX prefix_course_idnumber_idx ON prefix_course (idnumber);
CREATE INDEX prefix_course_shortname_idx ON prefix_course (shortname);
@@ -259,6 +259,7 @@ CREATE TABLE prefix_user (
CONSTRAINT prefix_user_username_uk UNIQUE (username)
);
+CREATE UNIQUE INDEX prefix_user_username_uk ON prefix_user (username);
CREATE INDEX prefix_user_idnumber_idx ON prefix_user (idnumber);
CREATE INDEX prefix_user_auth_idx ON prefix_user (auth);
CREATE INDEX prefix_user_deleted_idx ON prefix_user (deleted);

0 comments on commit b692d2b

Please sign in to comment.