From: stronk7 Date: Sat, 11 Aug 2007 00:19:51 +0000 (+0000) Subject: Fixing the table (renaming + proper defaults). MDL-10572 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=056eb9862725e451f95bdde5d6d9e197e5401970;p=moodle.git Fixing the table (renaming + proper defaults). MDL-10572 --- diff --git a/blocks/search/block_search.php b/blocks/search/block_search.php index 643a0dfa3e..21f8e0a856 100644 --- a/blocks/search/block_search.php +++ b/blocks/search/block_search.php @@ -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 diff --git a/blocks/search/db/install.xml b/blocks/search/db/install.xml index 449f0af3c1..a6e590d999 100644 --- a/blocks/search/db/install.xml +++ b/blocks/search/db/install.xml @@ -1,26 +1,27 @@ - + - +
- - - - + + + + - - - + + - diff --git a/blocks/search/db/upgrade.php b/blocks/search/db/upgrade.php index 61d70ecaf8..d9d5d856bd 100644 --- a/blocks/search/db/upgrade.php +++ b/blocks/search/db/upgrade.php @@ -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; }