<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">
}
}
+
+ // 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
// 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