]> git.mjollnir.org Git - moodle.git/commitdiff
I fixed up the database creation
authormoodler <moodler>
Fri, 13 Jul 2007 06:44:31 +0000 (06:44 +0000)
committermoodler <moodler>
Fri, 13 Jul 2007 06:44:31 +0000 (06:44 +0000)
blocks/search/block_search.php
blocks/search/db/install.xml
blocks/search/db/mysql.php [deleted file]
blocks/search/db/mysql.sql [deleted file]
blocks/search/db/postgres7.php [deleted file]
blocks/search/db/postgres7.sql [deleted file]
blocks/search/db/upgrade.php

index f696c716f028ee054d214418fb9cf06fe51a95e1..643a0dfa3e979510490de147637bf3626069f7b0 100644 (file)
@@ -16,7 +16,7 @@
     function init() {
       $this->title = get_string('blockname', 'block_search');
       $this->cron = 1;
-      $this->version = 2007062900;
+      $this->version = 2007071302;
     } //init  
     
     // only one instance of this block is required
@@ -82,4 +82,4 @@
       
   } //block_search
 
-?>
\ No newline at end of file
+?>
index 724409018b1f2d14f33cb863b2eb5b3b69c896eb..449f0af3c1068a657fe47b9ff4c90c1b7c5c5554 100644 (file)
@@ -9,19 +9,21 @@
         <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="docdate" TYPE="datetime" NOTNULL="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="url" NEXT="updated"/>
-        <FIELD NAME="updated" TYPE="datetime" NOTNULL="true" DEFAULT="CURRENT_TIMESTAMP" SEQUENCE="false" ENUM="false" PREVIOUS="docdate" NEXT="courseid"/>
-        <FIELD NAME="courseid" TYPE="int" LENGTH="11" NOTNULL="true" DEFAULT="0" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="updated" NEXT="groupid"/>
-        <FIELD NAME="groupid" TYPE="int" LENGTH="11" NOTNULL="true" DEFAULT="0" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="courseid"/>
+        <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"/>
       </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>
     </TABLE>
   </TABLES>
-</XMLDB>
\ No newline at end of file
+</XMLDB>
diff --git a/blocks/search/db/mysql.php b/blocks/search/db/mysql.php
deleted file mode 100644 (file)
index 48244ee..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to MySQL
-
-function search_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2007080100 and $result) {
-        modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` ADD `item_type` VARCHAR( 32 ) NOT NULL AFTER `doctype` ; ");
-        modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` ADD INDEX ( `item_type` ) ; ");
-        modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` CHANGE `doctype` `doctype` VARCHAR( 32 ) DEFAULT 'none' ; ");
-        modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` CHANGE `title` `title` VARCHAR( 255 ) ; ");
-        modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` CHANGE `url` `url` VARCHAR( 255 ) ; ");
-        modify_database ("", "ALTER TABLE `{$CFG->prefix}mdl_search_documents` CHANGE `docid` `docid` VARCHAR( 32 ) ; ");
-        $result = true;
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/search/db/mysql.sql b/blocks/search/db/mysql.sql
deleted file mode 100644 (file)
index 0f7969c..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-CREATE TABLE IF NOT EXISTS `prefix_search_documents` (
-  `id` int(11) NOT NULL auto_increment,
-  `docid` varchar(32) NOT NULL,
-  `doctype` varchar(32) NOT NULL default 'none',
-  `itemtype` varchar(32) NOT NULL default 'standard',
-  `title` varchar(255) NOT NULL default '',
-  `url` varchar(255) NOT NULL default '',
-  `docdate` timestamp NOT NULL default 0,
-  `updated` timestamp NOT NULL default CURRENT_TIMESTAMP,
-  `courseid` int(11) NOT NULL default 0,
-  `groupid` int(11) NOT NULL default 0,
-  PRIMARY KEY  (`id`)
-) ENGINE=MyISAM AUTO_INCREMENT=1;
diff --git a/blocks/search/db/postgres7.php b/blocks/search/db/postgres7.php
deleted file mode 100644 (file)
index b2d71b6..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-// THIS FILE IS DEPRECATED!  PLEASE DO NOT MAKE CHANGES TO IT!
-//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL 
-// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
-//
-// This file is tailored to pgsql
-
-function search_upgrade($oldversion=0) {
-
-    global $CFG;
-    
-    $result = true;
-
-    if ($oldversion < 2007080100 and $result) {
-        $result = true; //Nothing to do
-    }
-
-    //////  DO NOT ADD NEW THINGS HERE!!  USE upgrade.php and the lib/ddllib.php functions.
-
-    //Finally, return result
-    return $result;
-}
diff --git a/blocks/search/db/postgres7.sql b/blocks/search/db/postgres7.sql
deleted file mode 100644 (file)
index f8249b0..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-CREATE TABLE prefix_search_documents (
-   id SERIAL8 PRIMARY KEY,
-   docid int4 NOT NULL,
-   doctype varchar(12) NOT NULL default 'none',
-   itemtype varchar(32) NOT NULL default 'standard',
-   title varchar(255) NOT NULL default '',
-   url varchar(255) NOT NULL default '',
-   docdate timestamp NOT NULL,
-   updated timestamp NOT NULL default NOW(),
-   courseid int4,
-   groupid int4
-);
index 152d8b32cb9fbbfd062d2f10f0517f45a57bb51d..61d70ecaf8ed2c9faadd79f72fe018470a9a0c96 100644 (file)
@@ -31,6 +31,38 @@ function xmldb_block_search_upgrade($oldversion=0) {
 /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
 ///     $result = result of "/lib/ddllib.php" function calls
 /// }
+    if ($result && $oldversion < 2007071302) {
+
+    /// Define table search_documents to be created
+        $table = new XMLDBTable('search_documents');
+
+    /// Drop it if it existed before
+        
+        drop_table($table, true, false);
+
+    /// Adding fields to table search_documents
+        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+        $table->addFieldInfo('docid', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('doctype', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'none');
+        $table->addFieldInfo('itemtype', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'standard');
+        $table->addFieldInfo('title', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null);
+        $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');
+
+    /// Adding keys to table search_documents
+        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+
+    /// Adding indexes to table search_documents
+        $table->addIndexInfo('mdl_search_docid', XMLDB_INDEX_NOTUNIQUE, array('docid'));
+        $table->addIndexInfo('mdl_search_doctype', XMLDB_INDEX_NOTUNIQUE, array('doctype'));
+        $table->addIndexInfo('mdl_search_itemtype', XMLDB_INDEX_NOTUNIQUE, array('itemtype'));
+
+    /// Launch create table for search_documents
+        $result = $result && create_table($table);
+    }
 
     return $result;
 }