]> git.mjollnir.org Git - moodle.git/commitdiff
Add some checks to detect if one table exists before creating or
authorstronk7 <stronk7>
Sat, 30 Sep 2006 15:19:56 +0000 (15:19 +0000)
committerstronk7 <stronk7>
Sat, 30 Sep 2006 15:19:56 +0000 (15:19 +0000)
dropping it. Part of MDL-6614

lib/ddllib.php

index 5ae8dedfcc9fead547847b6953d0b700b0d80f1f..075a03683d2cb09546f87b25946083fb94f7d3a7 100644 (file)
@@ -478,6 +478,12 @@ function create_table($table, $continue=true, $feedback=true) {
         return false;
     }
 
+/// Check table doesn't exist
+    if (table_exists($table)) {
+        debugging('Table ' . $table->getName() . ' exists. Skipping its creation', DEBUG_DEVELOPER);
+        return true; //Table exists, nothing to do
+    }
+
     if(!$sqlarr = $table->getCreateTableSQL($CFG->dbtype, $CFG->prefix, false)) {
         return true; //Empty array = nothing to do = no error
     }
@@ -506,6 +512,12 @@ function drop_table($table, $continue=true, $feedback=true) {
         return false;
     }
 
+/// Check table exists
+    if (!table_exists($table)) {
+        debugging('Table ' . $table->getName() . ' don not exist. Skipping its deletion', DEBUG_DEVELOPER);
+        return true; //Table don't exist, nothing to do
+    }
+
     if(!$sqlarr = $table->getDropTableSQL($CFG->dbtype, $CFG->prefix, false)) {
         return true; //Empty array = nothing to do = no error
     }
@@ -813,7 +825,7 @@ function drop_index($table, $index, $continue=true, $feedback=true) {
 
 /// Check index exists
     if (!index_exists($table, $index)) {
-        debugging('Index ' . $index->getName() . ' do not exists. Skipping its deletion', DEBUG_DEVELOPER);
+        debugging('Index ' . $index->getName() . ' do not exist. Skipping its deletion', DEBUG_DEVELOPER);
         return true; //Index doesn't exist, nothing to do
     }