]> git.mxchange.org Git - friendica.git/blobdiff - include/dbstructure.php
so this is why my db updates were reverted ;-)
[friendica.git] / include / dbstructure.php
index 83a75e4d1b8a5fe4edf128feae927e6fa0651ce4..bdf6b8924692380879eca9e17b5abe66eefc4f26 100644 (file)
@@ -15,9 +15,6 @@ function dbstructure_run(&$argv, &$argc) {
                        unset($db_host, $db_user, $db_pass, $db_data);
        }
 
-       load_config('config');
-       load_config('system');
-
        update_structure(true, true);
 }
 
@@ -115,11 +112,11 @@ function update_structure($verbose, $action) {
        // Compare it
        foreach ($definition AS $name => $structure) {
                $sql3="";
-               if (!isset($database[$name]))
+               if (!isset($database[$name])) {
                        $r = db_create_table($name, $structure["fields"], $verbose, $action);
                         if(false === $r)
                                $errors .=  t('Errors encountered creating database tables.').$name.EOL;
-               else {
+               else {
                        // Compare the field structure field by field
                        foreach ($structure["fields"] AS $fieldname => $parameters) {
                                if (!isset($database[$name]["fields"][$fieldname])) {
@@ -155,14 +152,17 @@ function update_structure($verbose, $action) {
                                }
 
                // Create the index
-               foreach ($structure["indexes"] AS $indexname => $fieldnames)
+               foreach ($structure["indexes"] AS $indexname => $fieldnames) {
                        if (!isset($database[$name]["indexes"][$indexname])) {
                                $sql2=db_create_index($indexname, $fieldnames);
-                               if ($sql3 == "")
-                                       $sql3 = "ALTER TABLE `".$name."` ".$sql2;
-                               else
-                                       $sql3 .= ", ".$sql2;
+                               if ($sql2 != "") {
+                                       if ($sql3 == "")
+                                               $sql3 = "ALTER TABLE `".$name."` ".$sql2;
+                                       else
+                                               $sql3 .= ", ".$sql2;
+                               }
                        }
+               }
 
                if ($sql3 != "") {
                        $sql3 .= ";";
@@ -212,7 +212,7 @@ function db_create_table($name, $fields, $verbose, $action) {
                $sql .= "`".dbesc($fieldname)."` ".db_field_command($field);
        }
 
-       $sql = sprintf("ADD TABLE IF NOT EXISTS `%s` (\n", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
+       $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
 
        if ($verbose)
                echo $sql.";\n";
@@ -354,7 +354,7 @@ function db_definition() {
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
-                                       "access" => array("cat","k"),
+                                       "access" => array("cat(30)","k(30)"),
                                        )
                        );
        $database["contact"] = array(
@@ -621,7 +621,7 @@ function db_definition() {
        $database["guid"] = array(
                        "fields" => array(
                                        "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
-                                       "guid" => array("type" => "varchar(64)", "not null" => "1"),
+                                       "guid" => array("type" => "varchar(255)", "not null" => "1"),
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
@@ -638,7 +638,7 @@ function db_definition() {
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
-                                       "hook_file_function" => array("hook","file","function"),
+                                       "hook_file_function" => array("hook(30)","file(60)","function(30)"),
                                        )
                        );
        $database["intro"] = array(
@@ -662,7 +662,7 @@ function db_definition() {
        $database["item"] = array(
                        "fields" => array(
                                        "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
-                                       "guid" => array("type" => "varchar(64)", "not null" => "1"),
+                                       "guid" => array("type" => "varchar(255)", "not null" => "1"),
                                        "uri" => array("type" => "varchar(255)", "not null" => "1"),
                                        "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
                                        "contact-id" => array("type" => "int(11)", "not null" => "1"),
@@ -890,7 +890,7 @@ function db_definition() {
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
-                                       "access" => array("uid","cat","k"),
+                                       "access" => array("uid","cat(30)","k(30)"),
                                        )
                        );
        $database["photo"] = array(