]> git.mjollnir.org Git - moodle.git/commitdiff
adding a usermodified field to post table
authortoyomoyo <toyomoyo>
Tue, 5 Jun 2007 05:40:10 +0000 (05:40 +0000)
committertoyomoyo <toyomoyo>
Tue, 5 Jun 2007 05:40:10 +0000 (05:40 +0000)
lib/db/install.xml
lib/db/upgrade.php
version.php

index 34ae95012694ce1939f15aac8d3480d1304ea58b..e946e8528247e9ebdddafe079f3a68f043575497 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20070601" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20070605" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
         <FIELD NAME="attachment" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="attachment" PREVIOUS="format" NEXT="publishstate"/>
         <FIELD NAME="publishstate" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="draft" SEQUENCE="false" ENUM="true" ENUMVALUES="'draft', 'site', 'public'" PREVIOUS="attachment" NEXT="lastmodified"/>
         <FIELD NAME="lastmodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="publishstate" NEXT="created"/>
-        <FIELD NAME="created" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="lastmodified"/>
+        <FIELD NAME="created" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="lastmodified" NEXT="usermodified"/>
+        <FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="created"/>
       </FIELDS>
       <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for post"/>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for post" NEXT="usermodified"/>
+        <KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" COMMENT="Default comment for the key, please edit me" PREVIOUS="primary"/>
       </KEYS>
       <INDEXES>
         <INDEX NAME="id-userid" UNIQUE="true" FIELDS="id, userid" NEXT="lastmodified"/>
index 57c9d10634f438135dd0cac372871503f242ba1f..5a97b266eff3c85da8f6f31b1520b4ae322e4ee7 100644 (file)
@@ -1324,6 +1324,25 @@ function xmldb_main_upgrade($oldversion=0) {
         // Launch add field deleted
         $result = $result && add_field($table, $field); 
     }
+    
+    if ($result && $oldversion < 2007060500) {
+
+    /// Define field usermodified to be added to post
+        $table = new XMLDBTable('post');
+        $field = new XMLDBField('usermodified');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'created');
+
+    /// Launch add field usermodified
+        $result = $result && add_field($table, $field);
+        
+    /// Define key usermodified (foreign) to be added to post
+        $table = new XMLDBTable('post');
+        $key = new XMLDBKey('usermodified');
+        $key->setAttributes(XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
+
+    /// Launch add key usermodified
+        $result = $result && add_key($table, $key);
+    }
 
     return $result; 
 }
index 12d276dd1e33a59c882d365c458d7f1807d8013f..0e88b375d4f8c9d0ff6f7c3fe9627a081fd953bd 100644 (file)
@@ -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 = 2007060100;  // YYYYMMDD = date
+   $version = 2007060500;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.9 dev';    // Human-friendly version name