enforcing unique constraint on (courseid, shortname) pair on outcomes

This commit is contained in:
toyomoyo
2007-08-01 03:17:00 +00:00
parent 3a5ae6602b
commit 1f496dedfe
3 changed files with 14 additions and 2 deletions
+2 -1
View File
@@ -1290,7 +1290,8 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="courseid"/>
<KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary" NEXT="scaleid"/>
<KEY NAME="scaleid" TYPE="foreign" FIELDS="scaleid" REFTABLE="scale" REFFIELDS="id" PREVIOUS="courseid" NEXT="usermodified"/>
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" PREVIOUS="scaleid"/>
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" PREVIOUS="scaleid" NEXT="courseid-shortname"/>
<KEY NAME="courseid-shortname" TYPE="unique" FIELDS="courseid, shortname" COMMENT="Default comment for the key, please edit me" PREVIOUS="usermodified"/>
</KEYS>
</TABLE>
<TABLE NAME="grade_outcomes_courses" COMMENT="stores what outcomes are used in what courses." PREVIOUS="grade_outcomes" NEXT="grade_categories">
+11
View File
@@ -1553,7 +1553,18 @@ function xmldb_main_upgrade($oldversion=0) {
}
}
// adding unique contraint on (courseid,shortname) of an outcome
if ($result && $oldversion < 2007080100) {
/// Define key courseid-shortname (unique) to be added to grade_outcomes
$table = new XMLDBTable('grade_outcomes');
$key = new XMLDBKey('courseid-shortname');
$key->setAttributes(XMLDB_KEY_UNIQUE, array('courseid', 'shortname'));
/// Launch add key courseid-shortname
$result = $result && add_key($table, $key);
}
/*
/// drop old gradebook tables
+1 -1
View File
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2007073105; // YYYYMMDD = date
$version = 2007080100; // YYYYMMDD = date
// XY = increments within a single day
$release = '1.9 dev'; // Human-friendly version name