]> git.mjollnir.org Git - moodle.git/commitdiff
Conditionally execute create/drop table dbmanager functions. MDL-14955
authorstronk7 <stronk7>
Fri, 23 May 2008 22:24:00 +0000 (22:24 +0000)
committerstronk7 <stronk7>
Fri, 23 May 2008 22:24:00 +0000 (22:24 +0000)
admin/xmldb/actions/view_structure_php/view_structure_php.class.php

index 5fca953aaafa82c66f9b8a8ecc986dc9699b7f82..3e5846c127c4b39adb242ccabddd8ded647167d2 100644 (file)
@@ -211,8 +211,10 @@ class view_structure_php extends XMLDBAction {
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
-        $result .= '    /// Launch create table for ' . $table->getName() . XMLDB_LINEFEED;
-        $result .= '        $result = $result && create_table($table);' . XMLDB_LINEFEED;
+        $result .= '    /// Conditionally launch create table for ' . $table->getName() . XMLDB_LINEFEED;
+        $result .= '        if (!table_exists($table)) {' . XMLDB_LINEFEED;
+        $result .= '            $result = $result && create_table($table);' . XMLDB_LINEFEED;
+        $result .= '        }' . XMLDB_LINEFEED;
 
     /// Add the proper upgrade_xxxx_savepoint call
         $result .= $this->upgrade_savepoint_php ($structure);
@@ -252,8 +254,10 @@ class view_structure_php extends XMLDBAction {
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
-        $result .= '    /// Launch drop table for ' . $table->getName() . XMLDB_LINEFEED;
-        $result .= '        $result = $result && drop_table($table);' . XMLDB_LINEFEED;
+        $result .= '    /// Conditionally launch drop table for ' . $table->getName() . XMLDB_LINEFEED;
+        $result .= '        if (table_exists($table)) {' . XMLDB_LINEFEED;
+        $result .= '            $result = $result && drop_table($table);' . XMLDB_LINEFEED;
+        $result .= '        }' . XMLDB_LINEFEED;
 
     /// Add the proper upgrade_xxxx_savepoint call
         $result .= $this->upgrade_savepoint_php ($structure);