]> git.mxchange.org Git - friendica.git/blobdiff - include/dbstructure.php
Merge pull request #1518 from tugelbend/develop
[friendica.git] / include / dbstructure.php
index d25834edff801bae2b81a6bf98c7519073cc0084..012bb6f0bc857efa225ad0d44036f0a9272e9ce0 100644 (file)
@@ -120,7 +120,7 @@ function print_structure($database) {
        }
 }
 
-function update_structure($verbose, $action) {
+function update_structure($verbose, $action, $tables=null, $definition=null) {
        global $a, $db;
 
        $errors = false;
@@ -130,7 +130,8 @@ function update_structure($verbose, $action) {
        // Get the current structure
        $database = array();
 
-       $tables = q("show tables");
+       if (is_null($tables))
+               $tables = q("show tables");
 
        foreach ($tables AS $table) {
                $table = current($table);
@@ -139,7 +140,8 @@ function update_structure($verbose, $action) {
        }
 
        // Get the definition
-       $definition = db_definition();
+       if (is_null($definition))
+               $definition = db_definition();
 
        // Compare it
        foreach ($definition AS $name => $structure) {
@@ -149,9 +151,9 @@ function update_structure($verbose, $action) {
                         if(false === $r)
                                $errors .=  t('Errors encountered creating database tables.').$name.EOL;
                } else {
-                       // Drop the index if it isn't present in the definition
+                       // Drop the index if it isn't present in the definition and index name doesn't start with "local_"
                        foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
-                               if (!isset($structure["indexes"][$indexname])) {
+                               if (!isset($structure["indexes"][$indexname]) && substring($indexname, 0, 5) != 'local_') {
                                        $sql2=db_drop_index($indexname);
                                        if ($sql3 == "")
                                                $sql3 = "ALTER TABLE `".$name."` ".$sql2;