MDL-49795 core: Add foreign keys to core tables in lib
- Includes changes to tables like course, enrol, stage, etc
This commit is contained in:
+59
-1
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20220531" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20220616" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -108,6 +108,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="originalcourseid" TYPE="foreign" FIELDS="originalcourseid" REFTABLE="course" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="category" UNIQUE="false" FIELDS="category"/>
|
||||
@@ -257,6 +258,7 @@
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id"/>
|
||||
<KEY NAME="roleid" TYPE="foreign" FIELDS="roleid" REFTABLE="role" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="enrol" UNIQUE="false" FIELDS="enrol"/>
|
||||
@@ -951,6 +953,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid"/>
|
||||
@@ -975,6 +978,7 @@
|
||||
<KEY NAME="oldid" TYPE="foreign" FIELDS="oldid" REFTABLE="scale" REFFIELDS="id"/>
|
||||
<KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id"/>
|
||||
<KEY NAME="loggeduser" TYPE="foreign" FIELDS="loggeduser" REFTABLE="user" REFFIELDS="id"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="action" UNIQUE="false" FIELDS="action" COMMENT="insert/update/delete"/>
|
||||
@@ -1126,6 +1130,8 @@
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
<KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id"/>
|
||||
<KEY NAME="coursemoduleid" TYPE="foreign" FIELDS="coursemoduleid" REFTABLE="course_modules" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="id-userid" UNIQUE="true" FIELDS="id, userid"/>
|
||||
@@ -1622,6 +1628,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="question" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_response_analysis" COMMENT="Analysis of student responses given to questions.">
|
||||
@@ -1639,6 +1646,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="question" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_response_count" COMMENT="Count for each responses for each try at a question.">
|
||||
@@ -1688,6 +1696,9 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_host table"/>
|
||||
<KEY NAME="applicationid" TYPE="foreign" FIELDS="applicationid" REFTABLE="mnet_application" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="last_log_id" UNIQUE="false" FIELDS="last_log_id"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="mnet_host2service" COMMENT="Information about the services for a given host">
|
||||
<FIELDS>
|
||||
@@ -1813,6 +1824,8 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_session table"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
|
||||
<KEY NAME="mnethostid" TYPE="foreign" FIELDS="mnethostid" REFTABLE="mnet_host" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="token" UNIQUE="true" FIELDS="token"/>
|
||||
@@ -2204,6 +2217,7 @@
|
||||
<KEY NAME="itemid" TYPE="foreign" FIELDS="itemid" REFTABLE="grade_items" REFFIELDS="id"/>
|
||||
<KEY NAME="newgradeitem" TYPE="foreign" FIELDS="newgradeitem" REFTABLE="grade_import_newitem" REFFIELDS="id"/>
|
||||
<KEY NAME="importer" TYPE="foreign" FIELDS="importer" REFTABLE="user" REFFIELDS="id" COMMENT="user who is importing"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="tag_coll" COMMENT="Defines different set of tags">
|
||||
@@ -2525,6 +2539,7 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="userfk" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" COMMENT="fk to user table"/>
|
||||
<KEY NAME="portfoliofk" TYPE="foreign" FIELDS="portfolio" REFTABLE="portfolio_instance" REFFIELDS="id" COMMENT="fk to portfolio_instance"/>
|
||||
<KEY NAME="tempdataid" TYPE="foreign" FIELDS="tempdataid" REFTABLE="portfolio_tempdata" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="portfolio_tempdata" COMMENT="stores temporary data for portfolio exports. the id of this table is used for the itemid for the temporary files area. cron can clean up stale records (and associated file data) after expirytime.">
|
||||
@@ -2637,6 +2652,7 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="sourcefileid" TYPE="foreign" FIELDS="sourcefileid" REFTABLE="files" REFFIELDS="id"/>
|
||||
<KEY NAME="destfileid" TYPE="foreign" FIELDS="destfileid" REFTABLE="files" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="repository" COMMENT="This table contains one entry for every configured external repository instance.">
|
||||
@@ -2665,6 +2681,8 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
|
||||
<KEY NAME="contextid" TYPE="foreign" FIELDS="contextid" REFTABLE="context" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="repository_instance_config" COMMENT="The config for intances">
|
||||
@@ -2910,6 +2928,7 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="contextid" TYPE="foreign" FIELDS="contextid" REFTABLE="context" REFFIELDS="id" COMMENT="Relates to context.id"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" COMMENT="Relates to user.id"/>
|
||||
<KEY NAME="scaleid" TYPE="foreign" FIELDS="scaleid" REFTABLE="scale" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="uniqueuserrating" UNIQUE="false" FIELDS="component, ratingarea, contextid, itemid" COMMENT="These fields define a unique user rating of an item"/>
|
||||
@@ -3026,7 +3045,11 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="hubcourseid" UNIQUE="false" FIELDS="hubcourseid"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="grading_areas" COMMENT="Identifies gradable areas where advanced grading can happen. For each area, the current active plugin can be set.">
|
||||
<FIELDS>
|
||||
@@ -3100,6 +3123,8 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="badge" COMMENT="Defines badge">
|
||||
@@ -3470,6 +3495,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="classname" UNIQUE="false" FIELDS="classname"/>
|
||||
@@ -3540,6 +3566,8 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="scaleid" TYPE="foreign" FIELDS="scaleid" REFTABLE="scale" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="idnumberframework" UNIQUE="true" FIELDS="competencyframeworkid, idnumber"/>
|
||||
@@ -3558,6 +3586,7 @@
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="courseidlink" TYPE="foreign-unique" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" COMMENT="Course foreign key."/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="competency_framework" COMMENT="List of competency frameworks.">
|
||||
@@ -3578,6 +3607,9 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="contextid" TYPE="foreign" FIELDS="contextid" REFTABLE="context" REFFIELDS="id"/>
|
||||
<KEY NAME="scaleid" TYPE="foreign" FIELDS="scaleid" REFTABLE="scale" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="idnumber" UNIQUE="true" FIELDS="idnumber"/>
|
||||
@@ -3598,6 +3630,7 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="courseidlink" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" COMMENT="Course foreign key."/>
|
||||
<KEY NAME="competencyid" TYPE="foreign" FIELDS="competencyid" REFTABLE="competency" REFFIELDS="id" COMMENT="Competency foreign key."/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="courseidruleoutcome" UNIQUE="false" FIELDS="courseid, ruleoutcome"/>
|
||||
@@ -3622,6 +3655,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="useridstatus" UNIQUE="false" FIELDS="userid, status"/>
|
||||
@@ -3644,6 +3678,8 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="contextid" TYPE="foreign" FIELDS="contextid" REFTABLE="context" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="competency_templatecomp" COMMENT="Link a competency to a learning plan template.">
|
||||
@@ -3660,6 +3696,7 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="templateidlink" TYPE="foreign" FIELDS="templateid" REFTABLE="competency_template" REFFIELDS="id" COMMENT="Template foreign key."/>
|
||||
<KEY NAME="competencyid" TYPE="foreign" FIELDS="competencyid" REFTABLE="competency" REFFIELDS="id" COMMENT="Competency foreign key."/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="competency_templatecohort" COMMENT="Default comment for the table, please edit me">
|
||||
@@ -3673,6 +3710,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="templateid" UNIQUE="false" FIELDS="templateid"/>
|
||||
@@ -3690,6 +3728,9 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="competencyid" TYPE="foreign" FIELDS="competencyid" REFTABLE="competency" REFFIELDS="id"/>
|
||||
<KEY NAME="relatedcompetencyid" TYPE="foreign" FIELDS="relatedcompetencyid" REFTABLE="competency" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="competency_usercomp" COMMENT="User competencies">
|
||||
@@ -3707,6 +3748,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="useridcompetency" UNIQUE="true" FIELDS="userid, competencyid"/>
|
||||
@@ -3726,6 +3768,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="useridcoursecomp" UNIQUE="true" FIELDS="userid, courseid, competencyid"/>
|
||||
@@ -3746,6 +3789,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="usercompetencyplan" UNIQUE="true" FIELDS="userid, competencyid, planid"/>
|
||||
@@ -3763,6 +3807,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="planidcompetencyid" UNIQUE="true" FIELDS="planid, competencyid"/>
|
||||
@@ -3787,6 +3832,9 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="contextid" TYPE="foreign" FIELDS="contextid" REFTABLE="context" REFFIELDS="id"/>
|
||||
<KEY NAME="actionuserid" TYPE="foreign" FIELDS="actionuserid" REFTABLE="user" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="usercompetencyid" UNIQUE="false" FIELDS="usercompetencyid"/>
|
||||
@@ -3806,6 +3854,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
|
||||
@@ -3822,6 +3871,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="userevidenceid" UNIQUE="false" FIELDS="userevidenceid"/>
|
||||
@@ -3843,6 +3893,7 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="cmidkey" TYPE="foreign" FIELDS="cmid" REFTABLE="course_modules" REFFIELDS="id" COMMENT="Foreign key on course modules table."/>
|
||||
<KEY NAME="competencyidkey" TYPE="foreign" FIELDS="competencyid" REFTABLE="competency" REFFIELDS="id" COMMENT="Foreign key on competency id."/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="cmidruleoutcome" UNIQUE="false" FIELDS="cmid, ruleoutcome" COMMENT="Index on cmid and outcome so we can quickly find what to do when an activity is completed."/>
|
||||
@@ -3862,6 +3913,7 @@
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="issuer_id_key" TYPE="foreign" FIELDS="issuerid" REFTABLE="oauth2_issuer" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="oauth2_issuer" COMMENT="Details for an oauth 2 connect identity issuer.">
|
||||
@@ -3908,6 +3960,7 @@
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="issueridkey" TYPE="foreign-unique" FIELDS="issuerid" REFTABLE="oauth2_issuer" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="oauth2_user_field_mapping" COMMENT="Mapping of oauth user fields to moodle fields.">
|
||||
@@ -3924,6 +3977,7 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="issuerkey" TYPE="foreign" FIELDS="issuerid" REFTABLE="oauth2_issuer" REFFIELDS="id"/>
|
||||
<KEY NAME="uniqinternal" TYPE="unique" FIELDS="issuerid, internalfield"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="course_completion_defaults" COMMENT="Default settings for activities completion">
|
||||
@@ -3965,6 +4019,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="enabledandtrained" UNIQUE="false" FIELDS="enabled, trained" COMMENT="Index on enabled and train"/>
|
||||
@@ -3988,6 +4043,7 @@
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="modelid" TYPE="foreign" FIELDS="modelid" REFTABLE="analytics_models" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="analytics_predictions" COMMENT="Predictions">
|
||||
@@ -4117,6 +4173,7 @@
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="issueridkey" TYPE="foreign-unique" FIELDS="issuerid" REFTABLE="oauth2_issuer" REFFIELDS="id"/>
|
||||
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="analytics_used_analysables" COMMENT="List of analysables used by each model">
|
||||
@@ -4371,6 +4428,7 @@
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="contextid" TYPE="foreign" FIELDS="contextid" REFTABLE="context" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="payment_gateways" COMMENT="Configuration for one gateway for one payment account">
|
||||
|
||||
@@ -2877,6 +2877,15 @@ privatefiles,moodle|/user/files.php';
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2022061500.00);
|
||||
|
||||
}
|
||||
|
||||
if ($oldversion < 2022072900.00) {
|
||||
// Call the helper function that updates the foreign keys and indexes in MDL-49795.
|
||||
upgrade_add_foreign_key_and_indexes();
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2022072900.00);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1534,3 +1534,339 @@ function upgrade_fix_file_timestamps() {
|
||||
|
||||
$recordset->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade helper to add foreign keys and indexes for MDL-49795
|
||||
*/
|
||||
function upgrade_add_foreign_key_and_indexes() {
|
||||
global $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
// Define key originalcourseid (foreign) to be added to course.
|
||||
$table = new xmldb_table('course');
|
||||
$key = new xmldb_key('originalcourseid', XMLDB_KEY_FOREIGN, ['originalcourseid'], 'course', ['id']);
|
||||
// Launch add key originalcourseid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key roleid (foreign) to be added to enrol.
|
||||
$table = new xmldb_table('enrol');
|
||||
$key = new xmldb_key('roleid', XMLDB_KEY_FOREIGN, ['roleid'], 'role', ['id']);
|
||||
// Launch add key roleid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key userid (foreign) to be added to scale.
|
||||
$table = new xmldb_table('scale');
|
||||
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
|
||||
// Launch add key userid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key userid (foreign) to be added to scale_history.
|
||||
$table = new xmldb_table('scale_history');
|
||||
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
|
||||
// Launch add key userid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key courseid (foreign) to be added to post.
|
||||
$table = new xmldb_table('post');
|
||||
$key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']);
|
||||
// Launch add key courseid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key coursemoduleid (foreign) to be added to post.
|
||||
$table = new xmldb_table('post');
|
||||
$key = new xmldb_key('coursemoduleid', XMLDB_KEY_FOREIGN, ['coursemoduleid'], 'course_modules', ['id']);
|
||||
// Launch add key coursemoduleid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key questionid (foreign) to be added to question_statistics.
|
||||
$table = new xmldb_table('question_statistics');
|
||||
$key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN, ['questionid'], 'question', ['id']);
|
||||
// Launch add key questionid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key questionid (foreign) to be added to question_response_analysis.
|
||||
$table = new xmldb_table('question_response_analysis');
|
||||
$key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN, ['questionid'], 'question', ['id']);
|
||||
// Launch add key questionid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define index last_log_id (not unique) to be added to mnet_host.
|
||||
$table = new xmldb_table('mnet_host');
|
||||
$index = new xmldb_index('last_log_id', XMLDB_INDEX_NOTUNIQUE, ['last_log_id']);
|
||||
// Conditionally launch add index last_log_id.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Define key userid (foreign) to be added to mnet_session.
|
||||
$table = new xmldb_table('mnet_session');
|
||||
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
|
||||
// Launch add key userid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key mnethostid (foreign) to be added to mnet_session.
|
||||
$table = new xmldb_table('mnet_session');
|
||||
$key = new xmldb_key('mnethostid', XMLDB_KEY_FOREIGN, ['mnethostid'], 'mnet_host', ['id']);
|
||||
// Launch add key mnethostid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key userid (foreign) to be added to grade_import_values.
|
||||
$table = new xmldb_table('grade_import_values');
|
||||
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
|
||||
// Launch add key userid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key tempdataid (foreign) to be added to portfolio_log.
|
||||
$table = new xmldb_table('portfolio_log');
|
||||
$key = new xmldb_key('tempdataid', XMLDB_KEY_FOREIGN, ['tempdataid'], 'portfolio_tempdata', ['id']);
|
||||
// Launch add key tempdataid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to file_conversion.
|
||||
$table = new xmldb_table('file_conversion');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key userid (foreign) to be added to repository_instances.
|
||||
$table = new xmldb_table('repository_instances');
|
||||
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
|
||||
// Launch add key userid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key contextid (foreign) to be added to repository_instances.
|
||||
$table = new xmldb_table('repository_instances');
|
||||
$key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']);
|
||||
// Launch add key contextid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key scaleid (foreign) to be added to rating.
|
||||
$table = new xmldb_table('rating');
|
||||
$key = new xmldb_key('scaleid', XMLDB_KEY_FOREIGN, ['scaleid'], 'scale', ['id']);
|
||||
// Launch add key scaleid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key courseid (foreign) to be added to course_published.
|
||||
$table = new xmldb_table('course_published');
|
||||
$key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']);
|
||||
// Launch add key courseid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define index hubcourseid (not unique) to be added to course_published.
|
||||
$table = new xmldb_table('course_published');
|
||||
$index = new xmldb_index('hubcourseid', XMLDB_INDEX_NOTUNIQUE, ['hubcourseid']);
|
||||
// Conditionally launch add index hubcourseid.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Define key courseid (foreign) to be added to event_subscriptions.
|
||||
$table = new xmldb_table('event_subscriptions');
|
||||
$key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']);
|
||||
// Launch add key courseid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key userid (foreign) to be added to event_subscriptions.
|
||||
$table = new xmldb_table('event_subscriptions');
|
||||
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
|
||||
// Launch add key userid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key userid (foreign) to be added to task_log.
|
||||
$table = new xmldb_table('task_log');
|
||||
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
|
||||
// Launch add key userid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key scaleid (foreign) to be added to competency.
|
||||
$table = new xmldb_table('competency');
|
||||
$key = new xmldb_key('scaleid', XMLDB_KEY_FOREIGN, ['scaleid'], 'scale', ['id']);
|
||||
// Launch add key scaleid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency.
|
||||
$table = new xmldb_table('competency');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_coursecompsetting.
|
||||
$table = new xmldb_table('competency_coursecompsetting');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key contextid (foreign) to be added to competency_framework.
|
||||
$table = new xmldb_table('competency_framework');
|
||||
$key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']);
|
||||
// Launch add key contextid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key scaleid (foreign) to be added to competency_framework.
|
||||
$table = new xmldb_table('competency_framework');
|
||||
$key = new xmldb_key('scaleid', XMLDB_KEY_FOREIGN, ['scaleid'], 'scale', ['id']);
|
||||
// Launch add key scaleid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_framework.
|
||||
$table = new xmldb_table('competency_framework');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_coursecomp.
|
||||
$table = new xmldb_table('competency_coursecomp');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key actionuserid (foreign) to be added to competency_evidence.
|
||||
$table = new xmldb_table('competency_evidence');
|
||||
$key = new xmldb_key('actionuserid', XMLDB_KEY_FOREIGN, ['actionuserid'], 'user', ['id']);
|
||||
// Launch add key actionuserid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key contextid (foreign) to be added to competency_evidence.
|
||||
$table = new xmldb_table('competency_evidence');
|
||||
$key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']);
|
||||
// Launch add key contextid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_evidence.
|
||||
$table = new xmldb_table('competency_evidence');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_userevidence.
|
||||
$table = new xmldb_table('competency_userevidence');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_plan.
|
||||
$table = new xmldb_table('competency_plan');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_template.
|
||||
$table = new xmldb_table('competency_template');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key contextid (foreign) to be added to competency_template.
|
||||
$table = new xmldb_table('competency_template');
|
||||
$key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']);
|
||||
// Launch add key contextid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_templatecomp.
|
||||
$table = new xmldb_table('competency_templatecomp');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_templatecohort.
|
||||
$table = new xmldb_table('competency_templatecohort');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key relatedcompetencyid (foreign) to be added to competency_relatedcomp.
|
||||
$table = new xmldb_table('competency_relatedcomp');
|
||||
$key = new xmldb_key('relatedcompetencyid', XMLDB_KEY_FOREIGN, ['relatedcompetencyid'], 'competency', ['id']);
|
||||
// Launch add key relatedcompetencyid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key relatedcompetencyid (foreign) to be added to competency_relatedcomp.
|
||||
$table = new xmldb_table('competency_relatedcomp');
|
||||
$key = new xmldb_key('relatedcompetencyid', XMLDB_KEY_FOREIGN, ['relatedcompetencyid'], 'competency', ['id']);
|
||||
// Launch add key relatedcompetencyid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_relatedcomp.
|
||||
$table = new xmldb_table('competency_relatedcomp');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_usercomp.
|
||||
$table = new xmldb_table('competency_usercomp');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_usercompcourse.
|
||||
$table = new xmldb_table('competency_usercompcourse');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_usercompplan.
|
||||
$table = new xmldb_table('competency_usercompplan');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_plancomp.
|
||||
$table = new xmldb_table('competency_plancomp');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_userevidencecomp.
|
||||
$table = new xmldb_table('competency_userevidencecomp');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to competency_modulecomp.
|
||||
$table = new xmldb_table('competency_modulecomp');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to oauth2_endpoint.
|
||||
$table = new xmldb_table('oauth2_endpoint');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to oauth2_system_account.
|
||||
$table = new xmldb_table('oauth2_system_account');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to oauth2_user_field_mapping.
|
||||
$table = new xmldb_table('oauth2_user_field_mapping');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to analytics_models.
|
||||
$table = new xmldb_table('analytics_models');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to analytics_models_log.
|
||||
$table = new xmldb_table('analytics_models_log');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key usermodified (foreign) to be added to oauth2_access_token.
|
||||
$table = new xmldb_table('oauth2_access_token');
|
||||
$key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
|
||||
// Launch add key usermodified.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define key contextid (foreign) to be added to payment_accounts.
|
||||
$table = new xmldb_table('payment_accounts');
|
||||
$key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']);
|
||||
// Launch add key contextid.
|
||||
$dbman->add_key($table, $key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user