I fixed up the database creation

This commit is contained in:
moodler 2007-07-13 06:44:31 +00:00
parent e662a443e7
commit 6c4af359b9
7 changed files with 41 additions and 86 deletions

View 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
?>
?>

View 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>
</XMLDB>

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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
);

View 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;
}