mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-11016, MDL-11015 improvements to the tag, tag_instance and tag_correlation tables
This commit is contained in:
parent
522b89d1aa
commit
c4956945c1
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20070827" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20070828" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@ -1585,17 +1585,18 @@
|
||||
<TABLE NAME="tag" COMMENT="Tag table - this generic table will replace the old "tags" table." PREVIOUS="grade_import_values" NEXT="tag_correlation">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="rawname"/>
|
||||
<FIELD NAME="rawname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="The raw, unnormalised name for the tag as entered by users" PREVIOUS="name" NEXT="tagtype"/>
|
||||
<FIELD NAME="tagtype" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="rawname" NEXT="description"/>
|
||||
<FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="tagtype" NEXT="descriptionformat"/>
|
||||
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="flag"/>
|
||||
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="flag"/>
|
||||
<FIELD NAME="flag" TYPE="int" LENGTH="4" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="a tag can be 'flagged' as inappropriate" PREVIOUS="descriptionformat" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="flag"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for tag"/>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for tag" NEXT="userid"/>
|
||||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="name" UNIQUE="true" FIELDS="name" COMMENT="tag names are unique"/>
|
||||
@ -1604,30 +1605,29 @@
|
||||
<TABLE NAME="tag_correlation" COMMENT="The rationale for the 'tag_correlation' table is performance. It works as a cache for a potentially heavy load query done at the 'tag_instance' table. So, the 'tag_correlation' table stores redundant information derived from the 'tag_instance' table" PREVIOUS="tag" NEXT="tag_instance">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="tagid"/>
|
||||
<FIELD NAME="tagid" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="correlatedtags"/>
|
||||
<FIELD NAME="tagid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="correlatedtags"/>
|
||||
<FIELD NAME="correlatedtags" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="tagid"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for tag_correlation"/>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for tag_correlation" NEXT="tagid"/>
|
||||
<KEY NAME="tagid" TYPE="foreign" FIELDS="tagid" REFTABLE="tag" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="tagid" UNIQUE="true" FIELDS="tagid" COMMENT="tagid"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="tag_instance" COMMENT="tag_instance table holds the information of associations between tags and other items" PREVIOUS="tag_correlation" NEXT="groups">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="tagid"/>
|
||||
<FIELD NAME="tagid" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="itemtype"/>
|
||||
<FIELD NAME="tagid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="itemtype"/>
|
||||
<FIELD NAME="itemtype" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="tagid" NEXT="itemid"/>
|
||||
<FIELD NAME="itemid" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="itemtype" NEXT="ordering"/>
|
||||
<FIELD NAME="ordering" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" ENUM="false" COMMENT="Maintains the order of the tag instances of an item" PREVIOUS="itemid" NEXT="timemodified"/>
|
||||
<FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="itemtype" NEXT="ordering"/>
|
||||
<FIELD NAME="ordering" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="Maintains the order of the tag instances of an item" PREVIOUS="itemid" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="timemodified" PREVIOUS="ordering"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for tag_instance"/>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for tag_instance" NEXT="tagid"/>
|
||||
<KEY NAME="tagid" TYPE="foreign" FIELDS="tagid" REFTABLE="tag" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="tagiditem" UNIQUE="true" FIELDS="tagid, itemtype, itemid"/>
|
||||
<INDEX NAME="itemtype-itemid-tagid" UNIQUE="true" FIELDS="itemtype, itemid, tagid"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="groups" COMMENT="Each record represents a group." PREVIOUS="tag_instance" NEXT="groupings">
|
||||
|
@ -1833,6 +1833,109 @@ function xmldb_main_upgrade($oldversion=0) {
|
||||
$table = new XMLDBTable('blog_tag_instance');
|
||||
drop_table($table);
|
||||
}
|
||||
|
||||
/// MDL-11015, MDL-11016
|
||||
if ($result && $oldversion < 2007082800) {
|
||||
|
||||
/// Changing type of field userid on table tag to int
|
||||
$table = new XMLDBTable('tag');
|
||||
$field = new XMLDBField('userid');
|
||||
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
|
||||
|
||||
/// Launch change of type for field userid
|
||||
$result = $result && change_field_type($table, $field);
|
||||
|
||||
/// Changing type of field descriptionformat on table tag to int
|
||||
$table = new XMLDBTable('tag');
|
||||
$field = new XMLDBField('descriptionformat');
|
||||
$field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'description');
|
||||
|
||||
/// Launch change of type for field descriptionformat
|
||||
$result = $result && change_field_type($table, $field);
|
||||
|
||||
/// Define key userid (foreign) to be added to tag
|
||||
$table = new XMLDBTable('tag');
|
||||
$key = new XMLDBKey('userid');
|
||||
$key->setAttributes(XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
||||
|
||||
/// Launch add key userid
|
||||
$result = $result && add_key($table, $key);
|
||||
|
||||
/// Define index tagiditem (unique) to be dropped form tag_instance
|
||||
$table = new XMLDBTable('tag_instance');
|
||||
$index = new XMLDBIndex('tagiditem');
|
||||
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('tagid', 'itemtype', 'itemid'));
|
||||
|
||||
/// Launch drop index tagiditem
|
||||
$result = $result && drop_index($table, $index);
|
||||
|
||||
/// Changing type of field tagid on table tag_instance to int
|
||||
$table = new XMLDBTable('tag_instance');
|
||||
$field = new XMLDBField('tagid');
|
||||
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
|
||||
|
||||
/// Launch change of type for field tagid
|
||||
$result = $result && change_field_type($table, $field);
|
||||
|
||||
/// Define key tagid (foreign) to be added to tag_instance
|
||||
$table = new XMLDBTable('tag_instance');
|
||||
$key = new XMLDBKey('tagid');
|
||||
$key->setAttributes(XMLDB_KEY_FOREIGN, array('tagid'), 'tag', array('id'));
|
||||
|
||||
/// Launch add key tagid
|
||||
$result = $result && add_key($table, $key);
|
||||
|
||||
/// Changing sign of field itemid on table tag_instance to unsigned
|
||||
$table = new XMLDBTable('tag_instance');
|
||||
$field = new XMLDBField('itemid');
|
||||
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'itemtype');
|
||||
|
||||
/// Launch change of sign for field itemid
|
||||
$result = $result && change_field_unsigned($table, $field);
|
||||
|
||||
/// Changing sign of field ordering on table tag_instance to unsigned
|
||||
$table = new XMLDBTable('tag_instance');
|
||||
$field = new XMLDBField('ordering');
|
||||
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'itemid');
|
||||
|
||||
/// Launch change of sign for field ordering
|
||||
$result = $result && change_field_unsigned($table, $field);
|
||||
|
||||
/// Define index itemtype-itemid-tagid (unique) to be added to tag_instance
|
||||
$table = new XMLDBTable('tag_instance');
|
||||
$index = new XMLDBIndex('itemtype-itemid-tagid');
|
||||
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid'));
|
||||
|
||||
/// Launch add index itemtype-itemid-tagid
|
||||
$result = $result && add_index($table, $index);
|
||||
|
||||
/// Define index tagid (unique) to be dropped form tag_correlation
|
||||
$table = new XMLDBTable('tag_correlation');
|
||||
$index = new XMLDBIndex('tagid');
|
||||
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('tagid'));
|
||||
|
||||
/// Launch drop index tagid
|
||||
$result = $result && drop_index($table, $index);
|
||||
|
||||
/// Changing type of field tagid on table tag_correlation to int
|
||||
$table = new XMLDBTable('tag_correlation');
|
||||
$field = new XMLDBField('tagid');
|
||||
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
|
||||
|
||||
/// Launch change of type for field tagid
|
||||
$result = $result && change_field_type($table, $field);
|
||||
|
||||
|
||||
/// Define key tagid (foreign) to be added to tag_correlation
|
||||
$table = new XMLDBTable('tag_correlation');
|
||||
$key = new XMLDBKey('tagid');
|
||||
$key->setAttributes(XMLDB_KEY_FOREIGN, array('tagid'), 'tag', array('id'));
|
||||
|
||||
/// Launch add key tagid
|
||||
$result = $result && add_key($table, $key);
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -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 = 2007082701; // YYYYMMDD = date
|
||||
$version = 2007082800; // YYYYMMDD = date
|
||||
// XY = increments within a single day
|
||||
|
||||
$release = '1.9 Beta +'; // Human-friendly version name
|
||||
|
Loading…
x
Reference in New Issue
Block a user