]> git.mjollnir.org Git - moodle.git/commitdiff
Fixing the table (renaming + proper defaults). MDL-10572
authorstronk7 <stronk7>
Sat, 11 Aug 2007 00:19:51 +0000 (00:19 +0000)
committerstronk7 <stronk7>
Sat, 11 Aug 2007 00:19:51 +0000 (00:19 +0000)
blocks/search/block_search.php
blocks/search/db/install.xml
blocks/search/db/upgrade.php

index 643a0dfa3e979510490de147637bf3626069f7b0..21f8e0a856f749d05d94066491dce72a27256e9e 100644 (file)
@@ -16,7 +16,7 @@
     function init() {
       $this->title = get_string('blockname', 'block_search');
       $this->cron = 1;
-      $this->version = 2007071302;
+      $this->version = 2007081100;
     } //init  
     
     // only one instance of this block is required
index 449f0af3c1068a657fe47b9ff4c90c1b7c5c5554..a6e590d999ecc40284084ea0c853e97278f6f127 100644 (file)
@@ -1,26 +1,27 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="blocks/search/db" VERSION="20080801" COMMENT="XMLDB file for Moodle search engine">
+<XMLDB PATH="blocks/search/db" VERSION="20070811" COMMENT="XMLDB file for Moodle search engine"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
+>
   <TABLES>
-    <TABLE NAME="search_documents" COMMENT="table to store search index backups">
+    <TABLE NAME="block_search_documents" COMMENT="table to store search index backups">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="docid"/>
         <FIELD NAME="docid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="doctype"/>
-        <FIELD NAME="doctype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="'none'" SEQUENCE="false" ENUM="false" PREVIOUS="docid" NEXT="itemtype"/>
-        <FIELD NAME="itemtype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="'standard'" SEQUENCE="false" ENUM="false" PREVIOUS="doctype" NEXT="title"/>
-        <FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="''" SEQUENCE="false" ENUM="false" PREVIOUS="itemtype" NEXT="url"/>
-        <FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="''" SEQUENCE="false" ENUM="false" PREVIOUS="title" NEXT="docdate"/>
+        <FIELD NAME="doctype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="none" SEQUENCE="false" ENUM="false" PREVIOUS="docid" NEXT="itemtype"/>
+        <FIELD NAME="itemtype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="standard" SEQUENCE="false" ENUM="false" PREVIOUS="doctype" NEXT="title"/>
+        <FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="itemtype" NEXT="url"/>
+        <FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="title" NEXT="docdate"/>
         <FIELD NAME="docdate" TYPE="datetime" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="url" NEXT="updated"/>
-
         <FIELD NAME="updated" TYPE="datetime" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="docdate" NEXT="courseid"/>
-        <FIELD NAME="courseid" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="updated" NEXT="groupid"/>
-        <FIELD NAME="groupid" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid"/>
+        <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="updated" NEXT="groupid"/>
+        <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for block"/>
       </KEYS>
       <INDEXES>
         <INDEX NAME="mdl_search_docid" UNIQUE="false" FIELDS="docid" NEXT="mdl_search_doctype"/>
-
         <INDEX NAME="mdl_search_doctype" UNIQUE="false" FIELDS="doctype" PREVIOUS="mdl_search_docid" NEXT="mdl_search_itemtype"/>
         <INDEX NAME="mdl_search_itemtype" UNIQUE="false" FIELDS="itemtype" PREVIOUS="mdl_search_doctype"/>
       </INDEXES>
index 61d70ecaf8ed2c9faadd79f72fe018470a9a0c96..d9d5d856bd08283ce28ecc9a3c4ea89a7cb46bc9 100644 (file)
@@ -37,7 +37,7 @@ function xmldb_block_search_upgrade($oldversion=0) {
         $table = new XMLDBTable('search_documents');
 
     /// Drop it if it existed before
-        
+
         drop_table($table, true, false);
 
     /// Adding fields to table search_documents
@@ -49,8 +49,8 @@ function xmldb_block_search_upgrade($oldversion=0) {
         $table->addFieldInfo('url', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null);
         $table->addFieldInfo('docdate', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL, null, null, null);
         $table->addFieldInfo('updated', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL, null, null, null);
-        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '11', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('groupid', XMLDB_TYPE_INTEGER, '11', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
 
     /// Adding keys to table search_documents
         $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
@@ -64,6 +64,49 @@ function xmldb_block_search_upgrade($oldversion=0) {
         $result = $result && create_table($table);
     }
 
+/// Rename table search_documents to block_search_documents and 
+/// fix some defaults (MDL-10572)
+    if ($result && $oldversion < 2007081100) {
+
+    /// Define table search_documents to be renamed to block_search_documents
+        $table = new XMLDBTable('search_documents');
+
+    /// Launch rename table for block_search_documents
+        $result = $result && rename_table($table, 'block_search_documents');
+
+    /// Changing the default of field doctype on table block_search_documents to none
+        $table = new XMLDBTable('block_search_documents');
+        $field = new XMLDBField('doctype');
+        $field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'none', 'docid');
+
+    /// Launch change of default for field doctype
+        $result = $result && change_field_default($table, $field);
+
+   /// Changing the default of field itemtype on table block_search_documents to standard
+        $table = new XMLDBTable('block_search_documents');
+        $field = new XMLDBField('itemtype');
+        $field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'standard', 'doctype');
+
+    /// Launch change of default for field itemtype
+        $result = $result && change_field_default($table, $field);
+
+    /// Changing the default of field title on table block_search_documents to drop it
+        $table = new XMLDBTable('block_search_documents');
+        $field = new XMLDBField('title');
+        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'itemtype');
+
+    /// Launch change of default for field title
+        $result = $result && change_field_default($table, $field);
+
+    /// Changing the default of field url on table block_search_documents to drop it
+        $table = new XMLDBTable('block_search_documents');
+        $field = new XMLDBField('url');
+        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'title');
+
+    /// Launch change of default for field url
+        $result = $result && change_field_default($table, $field);
+    }
+
     return $result;
 }