]> git.mxchange.org Git - friendica.git/blob - src/Database/DBStructure.php
Corrected field names
[friendica.git] / src / Database / DBStructure.php
1 <?php
2 /**
3  * @file src/Database/DBStructure.php
4  */
5 namespace Friendica\Database;
6
7 use Friendica\Core\Config;
8 use Friendica\Database\DBM;
9 use dba;
10
11 require_once "boot.php";
12 require_once 'include/dba.php';
13 require_once 'include/enotify.php';
14 require_once "include/text.php";
15
16 /**
17  * @brief This class contain functions for the database management
18  *
19  * This class contains functions that doesn't need to know if pdo, mysqli or whatever is used.
20  */
21 class DBStructure {
22         /*
23          * Converts all tables from MyISAM to InnoDB
24          */
25         public static function convertToInnoDB() {
26                 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
27                         dbesc(dba::database_name()));
28
29                 if (!DBM::is_result($r)) {
30                         echo t('There are no tables on MyISAM.')."\n";
31                         return;
32                 }
33
34                 foreach ($r AS $table) {
35                         $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
36                         echo $sql."\n";
37
38                         $result = dba::e($sql);
39                         if (!DBM::is_result($result)) {
40                                 self::printUpdateError($sql);
41                         }
42                 }
43         }
44
45         /*
46          * send the email and do what is needed to do on update fails
47          *
48          * @param update_id             (int) number of failed update
49          * @param error_message (str) error message
50          */
51         public static function updateFail($update_id, $error_message) {
52                 $a = get_app();
53
54                 //send the administrators an e-mail
55                 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
56                 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
57                         $admin_mail_list
58                 );
59
60                 // No valid result?
61                 if (!DBM::is_result($adminlist)) {
62                         logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
63
64                         // Don't continue
65                         return;
66                 }
67
68                 // every admin could had different language
69                 foreach ($adminlist as $admin) {
70                         $lang = (($admin['language'])?$admin['language']:'en');
71                         push_lang($lang);
72
73                         $preamble = deindent(t("
74                                 The friendica developers released update %s recently,
75                                 but when I tried to install it, something went terribly wrong.
76                                 This needs to be fixed soon and I can't do it alone. Please contact a
77                                 friendica developer if you can not help me on your own. My database might be invalid."));
78                         $body = t("The error message is\n[pre]%s[/pre]");
79                         $preamble = sprintf($preamble, $update_id);
80                         $body = sprintf($body, $error_message);
81
82                         notification(array(
83                                 'type' => SYSTEM_EMAIL,
84                                 'to_email' => $admin['email'],
85                                 'preamble' => $preamble,
86                                 'body' => $body,
87                                 'language' => $lang)
88                         );
89                 }
90
91                 //try the logger
92                 logger("CRITICAL: Database structure update failed: ".$error_message);
93         }
94
95
96         private static function tableStructure($table) {
97                 $structures = q("DESCRIBE `%s`", $table);
98
99                 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
100
101                 $indexes = q("SHOW INDEX FROM `%s`", $table);
102
103                 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
104
105                 if (DBM::is_result($table_status)) {
106                         $table_status = $table_status[0];
107                 } else {
108                         $table_status = array();
109                 }
110
111                 $fielddata = array();
112                 $indexdata = array();
113
114                 if (DBM::is_result($indexes)) {
115                         foreach ($indexes AS $index) {
116                                 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
117                                         $indexdata[$index["Key_name"]] = array('UNIQUE');
118                                 }
119
120                                 $column = $index["Column_name"];
121
122                                 if ($index["Sub_part"] != "") {
123                                         $column .= "(".$index["Sub_part"].")";
124                                 }
125
126                                 $indexdata[$index["Key_name"]][] = $column;
127                         }
128                 }
129                 if (DBM::is_result($structures)) {
130                         foreach ($structures AS $field) {
131                                 $fielddata[$field["Field"]]["type"] = $field["Type"];
132                                 if ($field["Null"] == "NO") {
133                                         $fielddata[$field["Field"]]["not null"] = true;
134                                 }
135
136                                 if (isset($field["Default"])) {
137                                         $fielddata[$field["Field"]]["default"] = $field["Default"];
138                                 }
139
140                                 if ($field["Extra"] != "") {
141                                         $fielddata[$field["Field"]]["extra"] = $field["Extra"];
142                                 }
143
144                                 if ($field["Key"] == "PRI") {
145                                         $fielddata[$field["Field"]]["primary"] = true;
146                                 }
147                         }
148                 }
149                 if (DBM::is_result($full_columns)) {
150                         foreach ($full_columns AS $column) {
151                                 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
152                         }
153                 }
154
155                 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
156         }
157
158         public static function printStructure() {
159                 $database = self::definition();
160
161                 echo "-- ------------------------------------------\n";
162                 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
163                 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
164                 echo "-- ------------------------------------------\n\n\n";
165                 foreach ($database AS $name => $structure) {
166                         echo "--\n";
167                         echo "-- TABLE $name\n";
168                         echo "--\n";
169                         self::createTable($name, $structure['fields'], true, false, $structure["indexes"]);
170
171                         echo "\n";
172                 }
173         }
174
175         /**
176          * @brief Print out database error messages
177          *
178          * @param string $message Message to be added to the error message
179          *
180          * @return string Error message
181          */
182         private static function printUpdateError($message) {
183                 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
184                         dba::errorNo(), dba::errorMessage());
185
186                 return t('Errors encountered performing database changes: ').$message.EOL;
187         }
188
189         /**
190          * Updates DB structure and returns eventual errors messages
191          *
192          * @param bool  $verbose
193          * @param bool  $action     Whether to actually apply the update
194          * @param array $tables     An array of the database tables
195          * @param array $definition An array of the definition tables
196          * @return string Empty string if the update is successful, error messages otherwise
197          */
198         public static function update($verbose, $action, array $tables = null, array $definition = null) {
199                 if ($action) {
200                         Config::set('system', 'maintenance', 1);
201                         Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), DBM::date().' '.date('e')));
202                 }
203
204                 $errors = '';
205
206                 logger('updating structure', LOGGER_DEBUG);
207
208                 // Get the current structure
209                 $database = array();
210
211                 if (is_null($tables)) {
212                         $tables = q("SHOW TABLES");
213                 }
214
215                 if (DBM::is_result($tables)) {
216                         foreach ($tables AS $table) {
217                                 $table = current($table);
218
219                                 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
220                                 $database[$table] = self::tableStructure($table);
221                         }
222                 }
223
224                 // Get the definition
225                 if (is_null($definition)) {
226                         $definition = self::definition();
227                 }
228
229                 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
230                 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
231                         !(strpos(dba::server_info(), 'MariaDB') !== false)) {
232                         $ignore = '';
233                 } else {
234                         $ignore = ' IGNORE';
235                 }
236
237                 // Compare it
238                 foreach ($definition AS $name => $structure) {
239                         $is_new_table = False;
240                         $group_by = "";
241                         $sql3 = "";
242                         if (!isset($database[$name])) {
243                                 $r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']);
244                                 if (!DBM::is_result($r)) {
245                                         $errors .= self::printUpdateError($name);
246                                 }
247                                 $is_new_table = True;
248                         } else {
249                                 $is_unique = false;
250                                 $temp_name = $name;
251
252                                 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
253                                         if (isset($database[$name]["indexes"][$indexname])) {
254                                                 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
255                                         } else {
256                                                 $current_index_definition = "__NOT_SET__";
257                                         }
258                                         $new_index_definition = implode(",",$fieldnames);
259                                         if ($current_index_definition != $new_index_definition) {
260                                                 if ($fieldnames[0] == "UNIQUE") {
261                                                         $is_unique = true;
262                                                         if ($ignore == "") {
263                                                                 $temp_name = "temp-".$name;
264                                                         }
265                                                 }
266                                         }
267                                 }
268
269                                 /*
270                                  * Drop the index if it isn't present in the definition
271                                  * or the definition differ from current status
272                                  * and index name doesn't start with "local_"
273                                  */
274                                 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
275                                         $current_index_definition = implode(",",$fieldnames);
276                                         if (isset($structure["indexes"][$indexname])) {
277                                                 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
278                                         } else {
279                                                 $new_index_definition = "__NOT_SET__";
280                                         }
281                                         if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
282                                                 $sql2=self::dropIndex($indexname);
283                                                 if ($sql3 == "") {
284                                                         $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
285                                                 } else {
286                                                         $sql3 .= ", ".$sql2;
287                                                 }
288                                         }
289                                 }
290                                 // Compare the field structure field by field
291                                 foreach ($structure["fields"] AS $fieldname => $parameters) {
292                                         if (!isset($database[$name]["fields"][$fieldname])) {
293                                                 $sql2=self::addTableField($fieldname, $parameters);
294                                                 if ($sql3 == "") {
295                                                         $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
296                                                 } else {
297                                                         $sql3 .= ", ".$sql2;
298                                                 }
299                                         } else {
300                                                 // Compare the field definition
301                                                 $field_definition = $database[$name]["fields"][$fieldname];
302
303                                                 // Remove the relation data that is used for the referential integrity
304                                                 unset($parameters['relation']);
305
306                                                 // We change the collation after the indexes had been changed.
307                                                 // This is done to avoid index length problems.
308                                                 // So here we always ensure that there is no need to change it.
309                                                 unset($parameters['Collation']);
310                                                 unset($field_definition['Collation']);
311
312                                                 $current_field_definition = implode(",", $field_definition);
313                                                 $new_field_definition = implode(",", $parameters);
314                                                 if ($current_field_definition != $new_field_definition) {
315                                                         $sql2 = self::modifyTableField($fieldname, $parameters);
316                                                         if ($sql3 == "") {
317                                                                 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
318                                                         } else {
319                                                                 $sql3 .= ", ".$sql2;
320                                                         }
321                                                 }
322                                         }
323                                 }
324                         }
325
326                         /*
327                          * Create the index if the index don't exists in database
328                          * or the definition differ from the current status.
329                          * Don't create keys if table is new
330                          */
331                         if (!$is_new_table) {
332                                 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
333                                         if (isset($database[$name]["indexes"][$indexname])) {
334                                                 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
335                                         } else {
336                                                 $current_index_definition = "__NOT_SET__";
337                                         }
338                                         $new_index_definition = implode(",",$fieldnames);
339                                         if ($current_index_definition != $new_index_definition) {
340                                                 $sql2 = self::createIndex($indexname, $fieldnames);
341
342                                                 // Fetch the "group by" fields for unique indexes
343                                                 if ($fieldnames[0] == "UNIQUE") {
344                                                         $group_by = self::groupBy($indexname, $fieldnames);
345                                                 }
346                                                 if ($sql2 != "") {
347                                                         if ($sql3 == "") {
348                                                                 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
349                                                         } else {
350                                                                 $sql3 .= ", ".$sql2;
351                                                         }
352                                                 }
353                                         }
354                                 }
355
356                                 if (isset($database[$name]["table_status"]["Collation"])) {
357                                         if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
358                                                 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
359
360                                                 if ($sql3 == "") {
361                                                         $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
362                                                 } else {
363                                                         $sql3 .= ", ".$sql2;
364                                                 }
365                                         }
366                                 }
367
368                                 if ($sql3 != "") {
369                                         $sql3 .= "; ";
370                                 }
371
372                                 // Now have a look at the field collations
373                                 // Compare the field structure field by field
374                                 foreach ($structure["fields"] AS $fieldname => $parameters) {
375                                         // Compare the field definition
376                                         $field_definition = $database[$name]["fields"][$fieldname];
377
378                                         // Define the default collation if not given
379                                         if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
380                                                 $parameters['Collation'] = 'utf8mb4_general_ci';
381                                         } else {
382                                                 $parameters['Collation'] = null;
383                                         }
384
385                                         if ($field_definition['Collation'] != $parameters['Collation']) {
386                                                 $sql2 = self::modifyTableField($fieldname, $parameters);
387                                                 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
388                                                         $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
389                                                 } else {
390                                                         $sql3 .= ", ".$sql2;
391                                                 }
392                                         }
393                                 }
394                         }
395
396                         if ($sql3 != "") {
397                                 if (substr($sql3, -2, 2) != "; ") {
398                                         $sql3 .= ";";
399                                 }
400
401                                 $field_list = '';
402                                 if ($is_unique && $ignore == '') {
403                                         foreach ($database[$name]["fields"] AS $fieldname => $parameters) {
404                                                 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
405                                         }
406                                         $field_list = rtrim($field_list, ',');
407                                 }
408
409                                 if ($verbose) {
410                                         // Ensure index conversion to unique removes duplicates
411                                         if ($is_unique && ($temp_name != $name)) {
412                                                 if ($ignore != "") {
413                                                         echo "SET session old_alter_table=1;\n";
414                                                 } else {
415                                                         echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
416                                                         echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
417                                                 }
418                                         }
419
420                                         echo $sql3."\n";
421
422                                         if ($is_unique && ($temp_name != $name)) {
423                                                 if ($ignore != "") {
424                                                         echo "SET session old_alter_table=0;\n";
425                                                 } else {
426                                                         echo "INSERT INTO `".$temp_name."` SELECT ".dba::any_value_fallback($field_list)." FROM `".$name."`".$group_by.";\n";
427                                                         echo "DROP TABLE `".$name."`;\n";
428                                                         echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
429                                                 }
430                                         }
431                                 }
432
433                                 if ($action) {
434                                         Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), DBM::date().' '.date('e'), $name));
435
436                                         // Ensure index conversion to unique removes duplicates
437                                         if ($is_unique && ($temp_name != $name)) {
438                                                 if ($ignore != "") {
439                                                         dba::e("SET session old_alter_table=1;");
440                                                 } else {
441                                                         dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
442                                                         if (!DBM::is_result($r)) {
443                                                                 $errors .= self::printUpdateError($sql3);
444                                                                 return $errors;
445                                                         }
446
447                                                         $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
448                                                         if (!DBM::is_result($r)) {
449                                                                 $errors .= self::printUpdateError($sql3);
450                                                                 return $errors;
451                                                         }
452                                                 }
453                                         }
454
455                                         $r = dba::e($sql3);
456                                         if (!DBM::is_result($r)) {
457                                                 $errors .= self::printUpdateError($sql3);
458                                         }
459                                         if ($is_unique && ($temp_name != $name)) {
460                                                 if ($ignore != "") {
461                                                         dba::e("SET session old_alter_table=0;");
462                                                 } else {
463                                                         $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
464                                                         if (!DBM::is_result($r)) {
465                                                                 $errors .= self::printUpdateError($sql3);
466                                                                 return $errors;
467                                                         }
468                                                         $r = dba::e("DROP TABLE `".$name."`;");
469                                                         if (!DBM::is_result($r)) {
470                                                                 $errors .= self::printUpdateError($sql3);
471                                                                 return $errors;
472                                                         }
473                                                         $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
474                                                         if (!DBM::is_result($r)) {
475                                                                 $errors .= self::printUpdateError($sql3);
476                                                                 return $errors;
477                                                         }
478                                                 }
479                                         }
480                                 }
481                         }
482                 }
483
484                 if ($action) {
485                         Config::set('system', 'maintenance', 0);
486                         Config::set('system', 'maintenance_reason', '');
487                 }
488
489                 if ($errors) {
490                         Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
491                 } else {
492                         Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
493                 }
494
495                 return $errors;
496         }
497
498         private static function FieldCommand($parameters, $create = true) {
499                 $fieldstruct = $parameters["type"];
500
501                 if (!is_null($parameters["Collation"])) {
502                         $fieldstruct .= " COLLATE ".$parameters["Collation"];
503                 }
504
505                 if ($parameters["not null"]) {
506                         $fieldstruct .= " NOT NULL";
507                 }
508
509                 if (isset($parameters["default"])) {
510                         if (strpos(strtolower($parameters["type"]),"int")!==false) {
511                                 $fieldstruct .= " DEFAULT ".$parameters["default"];
512                         } else {
513                                 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
514                         }
515                 }
516                 if ($parameters["extra"] != "") {
517                         $fieldstruct .= " ".$parameters["extra"];
518                 }
519
520                 /*if (($parameters["primary"] != "") && $create)
521                         $fieldstruct .= " PRIMARY KEY";*/
522
523                 return($fieldstruct);
524         }
525
526         private static function createTable($name, $fields, $verbose, $action, $indexes=null) {
527                 $r = true;
528
529                 $sql_rows = array();
530                 $primary_keys = array();
531                 foreach ($fields AS $fieldname => $field) {
532                         $sql_rows[] = "`".dbesc($fieldname)."` ".self::FieldCommand($field);
533                         if (x($field,'primary') && $field['primary']!='') {
534                                 $primary_keys[] = $fieldname;
535                         }
536                 }
537
538                 if (!is_null($indexes)) {
539                         foreach ($indexes AS $indexname => $fieldnames) {
540                                 $sql_index = self::createIndex($indexname, $fieldnames, "");
541                                 if (!is_null($sql_index)) {
542                                         $sql_rows[] = $sql_index;
543                                 }
544                         }
545                 }
546
547                 $sql = implode(",\n\t", $sql_rows);
548
549                 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
550                 if ($verbose) {
551                         echo $sql.";\n";
552                 }
553
554                 if ($action) {
555                         $r = dba::e($sql);
556                 }
557
558                 return $r;
559         }
560
561         private static function addTableField($fieldname, $parameters) {
562                 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), self::FieldCommand($parameters));
563                 return($sql);
564         }
565
566         private static function modifyTableField($fieldname, $parameters) {
567                 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), self::FieldCommand($parameters, false));
568                 return($sql);
569         }
570
571         private static function dropIndex($indexname) {
572                 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
573                 return($sql);
574         }
575
576         private static function createIndex($indexname, $fieldnames, $method = "ADD") {
577                 $method = strtoupper(trim($method));
578                 if ($method!="" && $method!="ADD") {
579                         throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
580                 }
581
582                 if ($fieldnames[0] == "UNIQUE") {
583                         array_shift($fieldnames);
584                         $method .= ' UNIQUE';
585                 }
586
587                 $names = "";
588                 foreach ($fieldnames AS $fieldname) {
589                         if ($names != "") {
590                                 $names .= ",";
591                         }
592
593                         if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
594                                 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
595                         } else {
596                                 $names .= "`".dbesc($fieldname)."`";
597                         }
598                 }
599
600                 if ($indexname == "PRIMARY") {
601                         return sprintf("%s PRIMARY KEY(%s)", $method, $names);
602                 }
603
604
605                 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
606                 return($sql);
607         }
608
609         private static function groupBy($indexname, $fieldnames) {
610                 if ($fieldnames[0] != "UNIQUE") {
611                         return "";
612                 }
613
614                 array_shift($fieldnames);
615
616                 $names = "";
617                 foreach ($fieldnames AS $fieldname) {
618                         if ($names != "") {
619                                 $names .= ",";
620                         }
621
622                         if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
623                                 $names .= "`".dbesc($matches[1])."`";
624                         } else {
625                                 $names .= "`".dbesc($fieldname)."`";
626                         }
627                 }
628
629                 $sql = sprintf(" GROUP BY %s", $names);
630                 return $sql;
631         }
632
633         public static function definition() {
634                 $database = array();
635
636                 $database["addon"] = array(
637                                 "fields" => array(
638                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
639                                                 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
640                                                 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
641                                                 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
642                                                 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
643                                                 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
644                                                 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
645                                                 ),
646                                 "indexes" => array(
647                                                 "PRIMARY" => array("id"),
648                                                 "name" => array("UNIQUE", "name"),
649                                                 )
650                                 );
651                 $database["attach"] = array(
652                                 "fields" => array(
653                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
654                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
655                                                 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
656                                                 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
657                                                 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
658                                                 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
659                                                 "data" => array("type" => "longblob", "not null" => "1"),
660                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
661                                                 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
662                                                 "allow_cid" => array("type" => "mediumtext"),
663                                                 "allow_gid" => array("type" => "mediumtext"),
664                                                 "deny_cid" => array("type" => "mediumtext"),
665                                                 "deny_gid" => array("type" => "mediumtext"),
666                                                 ),
667                                 "indexes" => array(
668                                                 "PRIMARY" => array("id"),
669                                                 )
670                                 );
671                 $database["auth_codes"] = array(
672                                 "fields" => array(
673                                                 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
674                                                 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
675                                                 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
676                                                 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
677                                                 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
678                                                 ),
679                                 "indexes" => array(
680                                                 "PRIMARY" => array("id"),
681                                                 )
682                                 );
683                 $database["cache"] = array(
684                                 "fields" => array(
685                                                 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
686                                                 "v" => array("type" => "mediumtext"),
687                                                 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
688                                                 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
689                                                 ),
690                                 "indexes" => array(
691                                                 "PRIMARY" => array("k"),
692                                                 "expire_mode_updated" => array("expire_mode", "updated"),
693                                                 )
694                                 );
695                 $database["challenge"] = array(
696                                 "fields" => array(
697                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
698                                                 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699                                                 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
700                                                 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
701                                                 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
702                                                 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
703                                                 ),
704                                 "indexes" => array(
705                                                 "PRIMARY" => array("id"),
706                                                 )
707                                 );
708                 $database["clients"] = array(
709                                 "fields" => array(
710                                                 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
711                                                 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
712                                                 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
713                                                 "name" => array("type" => "text"),
714                                                 "icon" => array("type" => "text"),
715                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
716                                                 ),
717                                 "indexes" => array(
718                                                 "PRIMARY" => array("client_id"),
719                                                 )
720                                 );
721                 $database["config"] = array(
722                                 "fields" => array(
723                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
724                                                 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
725                                                 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
726                                                 "v" => array("type" => "mediumtext"),
727                                                 ),
728                                 "indexes" => array(
729                                                 "PRIMARY" => array("id"),
730                                                 "cat_k" => array("UNIQUE", "cat", "k"),
731                                                 )
732                                 );
733                 $database["contact"] = array(
734                                 "fields" => array(
735                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
736                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
737                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
738                                                 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
739                                                 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
740                                                 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
741                                                 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
742                                                 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743                                                 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744                                                 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745                                                 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746                                                 "about" => array("type" => "text"),
747                                                 "keywords" => array("type" => "text"),
748                                                 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
749                                                 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750                                                 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
751                                                 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752                                                 "photo" => array("type" => "text"),
753                                                 "thumb" => array("type" => "text"),
754                                                 "micro" => array("type" => "text"),
755                                                 "site-pubkey" => array("type" => "text"),
756                                                 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757                                                 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758                                                 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759                                                 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760                                                 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
761                                                 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
762                                                 "pubkey" => array("type" => "text"),
763                                                 "prvkey" => array("type" => "text"),
764                                                 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
765                                                 "request" => array("type" => "text"),
766                                                 "notify" => array("type" => "text"),
767                                                 "poll" => array("type" => "text"),
768                                                 "confirm" => array("type" => "text"),
769                                                 "poco" => array("type" => "text"),
770                                                 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771                                                 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
772                                                 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773                                                 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774                                                 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
775                                                 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
776                                                 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
777                                                 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
778                                                 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
779                                                 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
780                                                 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
781                                                 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
782                                                 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
783                                                 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
784                                                 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
785                                                 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
786                                                 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
787                                                 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788                                                 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789                                                 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
790                                                 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791                                                 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
792                                                 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
793                                                 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
794                                                 "reason" => array("type" => "text"),
795                                                 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
796                                                 "info" => array("type" => "mediumtext"),
797                                                 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
798                                                 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
799                                                 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
800                                                 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
801                                                 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
802                                                 "ffi_keyword_blacklist" => array("type" => "text"),
803                                                 ),
804                                 "indexes" => array(
805                                                 "PRIMARY" => array("id"),
806                                                 "uid_name" => array("uid", "name(190)"),
807                                                 "self_uid" => array("self", "uid"),
808                                                 "alias_uid" => array("alias(32)", "uid"),
809                                                 "pending_uid" => array("pending", "uid"),
810                                                 "blocked_uid" => array("blocked", "uid"),
811                                                 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
812                                                 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
813                                                 "addr_uid" => array("addr(32)", "uid"),
814                                                 "nurl_uid" => array("nurl(32)", "uid"),
815                                                 "nick_uid" => array("nick(32)", "uid"),
816                                                 "dfrn-id" => array("dfrn-id(64)"),
817                                                 "issued-id" => array("issued-id(64)"),
818                                                 )
819                                 );
820                 $database["conv"] = array(
821                                 "fields" => array(
822                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
823                                                 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
824                                                 "recips" => array("type" => "text"),
825                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
826                                                 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
827                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
828                                                 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
829                                                 "subject" => array("type" => "text"),
830                                                 ),
831                                 "indexes" => array(
832                                                 "PRIMARY" => array("id"),
833                                                 "uid" => array("uid"),
834                                                 )
835                                 );
836                 $database["conversation"] = array(
837                                 "fields" => array(
838                                                 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
839                                                 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
840                                                 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
841                                                 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
842                                                 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
843                                                 "source" => array("type" => "mediumtext"),
844                                                 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
845                                                 ),
846                                 "indexes" => array(
847                                                 "PRIMARY" => array("item-uri"),
848                                                 "conversation-uri" => array("conversation-uri"),
849                                                 "received" => array("received"),
850                                                 )
851                                 );
852                 $database["event"] = array(
853                                 "fields" => array(
854                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
855                                                 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
856                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
857                                                 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
858                                                 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
859                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
860                                                 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
861                                                 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
862                                                 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
863                                                 "summary" => array("type" => "text"),
864                                                 "desc" => array("type" => "text"),
865                                                 "location" => array("type" => "text"),
866                                                 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
867                                                 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
868                                                 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
869                                                 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
870                                                 "allow_cid" => array("type" => "mediumtext"),
871                                                 "allow_gid" => array("type" => "mediumtext"),
872                                                 "deny_cid" => array("type" => "mediumtext"),
873                                                 "deny_gid" => array("type" => "mediumtext"),
874                                                 ),
875                                 "indexes" => array(
876                                                 "PRIMARY" => array("id"),
877                                                 "uid_start" => array("uid", "start"),
878                                                 )
879                                 );
880                 $database["fcontact"] = array(
881                                 "fields" => array(
882                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
883                                                 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884                                                 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
885                                                 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
886                                                 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887                                                 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888                                                 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
889                                                 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890                                                 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891                                                 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
892                                                 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
893                                                 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
894                                                 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
895                                                 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
896                                                 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
897                                                 "pubkey" => array("type" => "text"),
898                                                 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
899                                                 ),
900                                 "indexes" => array(
901                                                 "PRIMARY" => array("id"),
902                                                 "addr" => array("addr(32)"),
903                                                 "url" => array("UNIQUE", "url(190)"),
904                                                 )
905                                 );
906                 $database["fsuggest"] = array(
907                                 "fields" => array(
908                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
909                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
910                                                 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
911                                                 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
912                                                 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
913                                                 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
914                                                 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
915                                                 "note" => array("type" => "text"),
916                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
917                                                 ),
918                                 "indexes" => array(
919                                                 "PRIMARY" => array("id"),
920                                                 )
921                                 );
922                 $database["gcign"] = array(
923                                 "fields" => array(
924                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
925                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
926                                                 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
927                                                 ),
928                                 "indexes" => array(
929                                                 "PRIMARY" => array("id"),
930                                                 "uid" => array("uid"),
931                                                 "gcid" => array("gcid"),
932                                                 )
933                                 );
934                 $database["gcontact"] = array(
935                                 "fields" => array(
936                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
937                                                 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
938                                                 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
939                                                 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
940                                                 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
941                                                 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
942                                                 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
943                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
944                                                 "updated" => array("type" => "datetime", "default" => NULL_DATE),
945                                                 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
946                                                 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
947                                                 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
948                                                 "about" => array("type" => "text"),
949                                                 "keywords" => array("type" => "text"),
950                                                 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
951                                                 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
952                                                 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
953                                                 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
954                                                 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
955                                                 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
956                                                 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
957                                                 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958                                                 "notify" => array("type" => "text"),
959                                                 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960                                                 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
961                                                 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962                                                 ),
963                                 "indexes" => array(
964                                                 "PRIMARY" => array("id"),
965                                                 "nurl" => array("UNIQUE", "nurl(190)"),
966                                                 "name" => array("name(64)"),
967                                                 "nick" => array("nick(32)"),
968                                                 "addr" => array("addr(64)"),
969                                                 "hide_network_updated" => array("hide", "network(4)", "updated"),
970                                                 "updated" => array("updated"),
971                                                 )
972                                 );
973                 $database["glink"] = array(
974                                 "fields" => array(
975                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
976                                                 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
977                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
978                                                 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
979                                                 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
980                                                 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
981                                                 ),
982                                 "indexes" => array(
983                                                 "PRIMARY" => array("id"),
984                                                 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
985                                                 "gcid" => array("gcid"),
986                                                 )
987                                 );
988                 $database["group"] = array(
989                                 "fields" => array(
990                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
991                                                 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
992                                                 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
993                                                 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
994                                                 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
995                                                 ),
996                                 "indexes" => array(
997                                                 "PRIMARY" => array("id"),
998                                                 "uid" => array("uid"),
999                                                 )
1000                                 );
1001                 $database["group_member"] = array(
1002                                 "fields" => array(
1003                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1004                                                 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1005                                                 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1006                                                 ),
1007                                 "indexes" => array(
1008                                                 "PRIMARY" => array("id"),
1009                                                 "contactid" => array("contact-id"),
1010                                                 "gid_contactid" => array("UNIQUE", "gid", "contact-id"),
1011                                                 )
1012                                 );
1013                 $database["gserver"] = array(
1014                                 "fields" => array(
1015                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1016                                                 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1017                                                 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1018                                                 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1019                                                 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1020                                                 "info" => array("type" => "text"),
1021                                                 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1022                                                 "registered-users" => array("type" => "int(10)", "not null" => "1", "default" => "0"),
1023                                                 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1024                                                 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1025                                                 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1026                                                 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1027                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1028                                                 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1029                                                 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1030                                                 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1031                                                 ),
1032                                 "indexes" => array(
1033                                                 "PRIMARY" => array("id"),
1034                                                 "nurl" => array("UNIQUE", "nurl(190)"),
1035                                                 )
1036                                 );
1037                 $database["hook"] = array(
1038                                 "fields" => array(
1039                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1040                                                 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041                                                 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1042                                                 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043                                                 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1044                                                 ),
1045                                 "indexes" => array(
1046                                                 "PRIMARY" => array("id"),
1047                                                 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1048                                                 )
1049                                 );
1050                 $database["intro"] = array(
1051                                 "fields" => array(
1052                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1053                                                 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1054                                                 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1055                                                 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1056                                                 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1057                                                 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1058                                                 "note" => array("type" => "text"),
1059                                                 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1060                                                 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1061                                                 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1062                                                 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1063                                                 ),
1064                                 "indexes" => array(
1065                                                 "PRIMARY" => array("id"),
1066                                                 )
1067                                 );
1068                 $database["item"] = array(
1069                                 "fields" => array(
1070                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1071                                                 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1072                                                 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1073                                                 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1074                                                 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1075                                                 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1076                                                 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1077                                                 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1078                                                 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1079                                                 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1080                                                 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1081                                                 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1082                                                 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1083                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1084                                                 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1085                                                 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1086                                                 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1087                                                 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1088                                                 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1089                                                 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1090                                                 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1091                                                 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1092                                                 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1093                                                 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094                                                 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1095                                                 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1096                                                 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1097                                                 "body" => array("type" => "mediumtext"),
1098                                                 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1099                                                 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1100                                                 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1101                                                 "object" => array("type" => "text"),
1102                                                 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103                                                 "target" => array("type" => "text"),
1104                                                 "postopts" => array("type" => "text"),
1105                                                 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106                                                 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1107                                                 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1108                                                 "tag" => array("type" => "mediumtext"),
1109                                                 "attach" => array("type" => "mediumtext"),
1110                                                 "inform" => array("type" => "mediumtext"),
1111                                                 "file" => array("type" => "mediumtext"),
1112                                                 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1113                                                 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1114                                                 "allow_cid" => array("type" => "mediumtext"),
1115                                                 "allow_gid" => array("type" => "mediumtext"),
1116                                                 "deny_cid" => array("type" => "mediumtext"),
1117                                                 "deny_gid" => array("type" => "mediumtext"),
1118                                                 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1119                                                 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1120                                                 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1121                                                 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1122                                                 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1123                                                 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1124                                                 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1125                                                 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1126                                                 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1127                                                 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1128                                                 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1129                                                 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1130                                                 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1131                                                 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1132                                                 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1133                                                 "rendered-html" => array("type" => "mediumtext"),
1134                                                 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1135                                                 ),
1136                                 "indexes" => array(
1137                                                 "PRIMARY" => array("id"),
1138                                                 "guid" => array("guid(191)"),
1139                                                 "uri" => array("uri(191)"),
1140                                                 "parent" => array("parent"),
1141                                                 "parent-uri" => array("parent-uri(191)"),
1142                                                 "extid" => array("extid(191)"),
1143                                                 "uid_id" => array("uid","id"),
1144                                                 "uid_contactid_id" => array("uid","contact-id","id"),
1145                                                 "uid_created" => array("uid","created"),
1146                                                 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1147                                                 "uid_network_received" => array("uid","network(4)","received"),
1148                                                 "uid_network_commented" => array("uid","network(4)","commented"),
1149                                                 "uid_thrparent" => array("uid","thr-parent(190)"),
1150                                                 "uid_parenturi" => array("uid","parent-uri(190)"),
1151                                                 "uid_contactid_created" => array("uid","contact-id","created"),
1152                                                 "authorid_created" => array("author-id","created"),
1153                                                 "ownerid" => array("owner-id"),
1154                                                 "uid_uri" => array("uid", "uri(190)"),
1155                                                 "resource-id" => array("resource-id(191)"),
1156                                                 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1157                                                 "uid_type_changed" => array("uid","type(190)","changed"),
1158                                                 "contactid_verb" => array("contact-id","verb(190)"),
1159                                                 "deleted_changed" => array("deleted","changed"),
1160                                                 "uid_wall_changed" => array("uid","wall","changed"),
1161                                                 "uid_eventid" => array("uid","event-id"),
1162                                                 "uid_authorlink" => array("uid","author-link(190)"),
1163                                                 "uid_ownerlink" => array("uid","owner-link(190)"),
1164                                                 )
1165                                 );
1166                 $database["locks"] = array(
1167                                 "fields" => array(
1168                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1169                                                 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1170                                                 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1171                                                 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1172                                                 ),
1173                                 "indexes" => array(
1174                                                 "PRIMARY" => array("id"),
1175                                                 )
1176                                 );
1177                 $database["mail"] = array(
1178                                 "fields" => array(
1179                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1180                                                 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1181                                                 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1182                                                 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1183                                                 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1184                                                 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1185                                                 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1186                                                 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1187                                                 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1188                                                 "body" => array("type" => "mediumtext"),
1189                                                 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1190                                                 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1191                                                 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1192                                                 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1193                                                 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1194                                                 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1195                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1196                                                 ),
1197                                 "indexes" => array(
1198                                                 "PRIMARY" => array("id"),
1199                                                 "uid_seen" => array("uid", "seen"),
1200                                                 "convid" => array("convid"),
1201                                                 "uri" => array("uri(64)"),
1202                                                 "parent-uri" => array("parent-uri(64)"),
1203                                                 "contactid" => array("contact-id(32)"),
1204                                                 )
1205                                 );
1206                 $database["mailacct"] = array(
1207                                 "fields" => array(
1208                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1209                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1210                                                 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1211                                                 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1212                                                 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1213                                                 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1214                                                 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1215                                                 "pass" => array("type" => "text"),
1216                                                 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1217                                                 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1218                                                 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1219                                                 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1220                                                 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1221                                                 ),
1222                                 "indexes" => array(
1223                                                 "PRIMARY" => array("id"),
1224                                                 )
1225                                 );
1226                 $database["manage"] = array(
1227                                 "fields" => array(
1228                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1229                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1230                                                 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1231                                                 ),
1232                                 "indexes" => array(
1233                                                 "PRIMARY" => array("id"),
1234                                                 "uid_mid" => array("UNIQUE", "uid","mid"),
1235                                                 )
1236                                 );
1237                 $database["notify"] = array(
1238                                 "fields" => array(
1239                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1240                                                 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1241                                                 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1242                                                 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1243                                                 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1244                                                 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1245                                                 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1246                                                 "msg" => array("type" => "mediumtext"),
1247                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1248                                                 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1249                                                 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1250                                                 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1251                                                 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1252                                                 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1253                                                 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1254                                                 "name_cache" => array("type" => "tinytext"),
1255                                                 "msg_cache" => array("type" => "mediumtext")
1256                                                 ),
1257                                 "indexes" => array(
1258                                                 "PRIMARY" => array("id"),
1259                                                 "hash_uid" => array("hash", "uid"),
1260                                                 "seen_uid_date" => array("seen", "uid", "date"),
1261                                                 "uid_date" => array("uid", "date"),
1262                                                 "uid_type_link" => array("uid", "type", "link(190)"),
1263                                                 )
1264                                 );
1265                 $database["notify-threads"] = array(
1266                                 "fields" => array(
1267                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1268                                                 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1269                                                 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1270                                                 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1271                                                 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1272                                                 ),
1273                                 "indexes" => array(
1274                                                 "PRIMARY" => array("id"),
1275                                                 )
1276                                 );
1277                 $database["oembed"] = array(
1278                                 "fields" => array(
1279                                                 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1280                                                 "maxwidth" => array("type" => "int(11)", "not null" => "1", "primary" => "1"),
1281                                                 "content" => array("type" => "mediumtext"),
1282                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1283                                                 ),
1284                                 "indexes" => array(
1285                                                 "PRIMARY" => array("url", "maxwidth"),
1286                                                 "created" => array("created"),
1287                                                 )
1288                                 );
1289                 $database["parsed_url"] = array(
1290                                 "fields" => array(
1291                                                 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1292                                                 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1293                                                 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1294                                                 "content" => array("type" => "mediumtext"),
1295                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1296                                                 ),
1297                                 "indexes" => array(
1298                                                 "PRIMARY" => array("url", "guessing", "oembed"),
1299                                                 "created" => array("created"),
1300                                                 )
1301                                 );
1302                 $database["participation"] = array(
1303                                 "fields" => array(
1304                                                 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1", "relation" => array("item" => "id")),
1305                                                 "server" => array("type" => "varchar(60)", "not null" => "1", "primary" => "1"),
1306                                                 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "relation" => array("contact" => "id")),
1307                                                 ),
1308                                 "indexes" => array(
1309                                                 "PRIMARY" => array("iid", "server")
1310                                                 )
1311                                 );
1312                 $database["pconfig"] = array(
1313                                 "fields" => array(
1314                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1315                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1316                                                 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1317                                                 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1318                                                 "v" => array("type" => "mediumtext"),
1319                                                 ),
1320                                 "indexes" => array(
1321                                                 "PRIMARY" => array("id"),
1322                                                 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1323                                                 )
1324                                 );
1325                 $database["photo"] = array(
1326                                 "fields" => array(
1327                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1328                                                 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1329                                                 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1330                                                 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1331                                                 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1332                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1333                                                 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1334                                                 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1335                                                 "desc" => array("type" => "text"),
1336                                                 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1337                                                 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1338                                                 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1339                                                 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1340                                                 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1341                                                 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1342                                                 "data" => array("type" => "mediumblob", "not null" => "1"),
1343                                                 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1344                                                 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1345                                                 "allow_cid" => array("type" => "mediumtext"),
1346                                                 "allow_gid" => array("type" => "mediumtext"),
1347                                                 "deny_cid" => array("type" => "mediumtext"),
1348                                                 "deny_gid" => array("type" => "mediumtext"),
1349                                                 ),
1350                                 "indexes" => array(
1351                                                 "PRIMARY" => array("id"),
1352                                                 "contactid" => array("contact-id"),
1353                                                 "uid_contactid" => array("uid", "contact-id"),
1354                                                 "uid_profile" => array("uid", "profile"),
1355                                                 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1356                                                 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1357                                                 "resource-id" => array("resource-id(64)"),
1358                                                 )
1359                                 );
1360                 $database["poll"] = array(
1361                                 "fields" => array(
1362                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1363                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1364                                                 "q0" => array("type" => "text"),
1365                                                 "q1" => array("type" => "text"),
1366                                                 "q2" => array("type" => "text"),
1367                                                 "q3" => array("type" => "text"),
1368                                                 "q4" => array("type" => "text"),
1369                                                 "q5" => array("type" => "text"),
1370                                                 "q6" => array("type" => "text"),
1371                                                 "q7" => array("type" => "text"),
1372                                                 "q8" => array("type" => "text"),
1373                                                 "q9" => array("type" => "text"),
1374                                                 ),
1375                                 "indexes" => array(
1376                                                 "PRIMARY" => array("id"),
1377                                                 "uid" => array("uid"),
1378                                                 )
1379                                 );
1380                 $database["poll_result"] = array(
1381                                 "fields" => array(
1382                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1383                                                 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1384                                                 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1385                                                 ),
1386                                 "indexes" => array(
1387                                                 "PRIMARY" => array("id"),
1388                                                 "poll_id" => array("poll_id"),
1389                                                 "choice" => array("choice"),
1390                                                 )
1391                                 );
1392                 $database["process"] = array(
1393                                 "fields" => array(
1394                                                 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1395                                                 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1396                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1397                                                 ),
1398                                 "indexes" => array(
1399                                                 "PRIMARY" => array("pid"),
1400                                                 "command" => array("command"),
1401                                                 )
1402                                 );
1403                 $database["profile"] = array(
1404                                 "fields" => array(
1405                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1406                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1407                                                 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1408                                                 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1409                                                 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1410                                                 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1411                                                 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1412                                                 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1413                                                 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1414                                                 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1415                                                 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1416                                                 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1417                                                 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1418                                                 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1419                                                 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1420                                                 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1421                                                 "with" => array("type" => "text"),
1422                                                 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1423                                                 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1424                                                 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1425                                                 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1426                                                 "pub_keywords" => array("type" => "text"),
1427                                                 "prv_keywords" => array("type" => "text"),
1428                                                 "likes" => array("type" => "text"),
1429                                                 "dislikes" => array("type" => "text"),
1430                                                 "about" => array("type" => "text"),
1431                                                 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1432                                                 "music" => array("type" => "text"),
1433                                                 "book" => array("type" => "text"),
1434                                                 "tv" => array("type" => "text"),
1435                                                 "film" => array("type" => "text"),
1436                                                 "interest" => array("type" => "text"),
1437                                                 "romance" => array("type" => "text"),
1438                                                 "work" => array("type" => "text"),
1439                                                 "education" => array("type" => "text"),
1440                                                 "contact" => array("type" => "text"),
1441                                                 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1442                                                 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1443                                                 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1444                                                 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1445                                                 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1446                                                 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1447                                                 ),
1448                                 "indexes" => array(
1449                                                 "PRIMARY" => array("id"),
1450                                                 "uid_is-default" => array("uid", "is-default"),
1451                                                 )
1452                                 );
1453                 $database["profile_check"] = array(
1454                                 "fields" => array(
1455                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1456                                                 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1457                                                 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1458                                                 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1459                                                 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1460                                                 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1461                                                 ),
1462                                 "indexes" => array(
1463                                                 "PRIMARY" => array("id"),
1464                                                 )
1465                                 );
1466                 $database["push_subscriber"] = array(
1467                                 "fields" => array(
1468                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1469                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1470                                                 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1471                                                 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1472                                                 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1473                                                 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1474                                                 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1475                                                 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1476                                                 ),
1477                                 "indexes" => array(
1478                                                 "PRIMARY" => array("id"),
1479                                                 )
1480                                 );
1481                 $database["queue"] = array(
1482                                 "fields" => array(
1483                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1484                                                 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1485                                                 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1486                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1487                                                 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1488                                                 "content" => array("type" => "mediumtext"),
1489                                                 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1490                                                 ),
1491                                 "indexes" => array(
1492                                                 "PRIMARY" => array("id"),
1493                                                 "cid" => array("cid"),
1494                                                 "created" => array("created"),
1495                                                 "last" => array("last"),
1496                                                 "network" => array("network"),
1497                                                 "batch" => array("batch"),
1498                                                 )
1499                                 );
1500                 $database["register"] = array(
1501                                 "fields" => array(
1502                                                 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1503                                                 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1504                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1505                                                 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1506                                                 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1507                                                 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1508                                                 "note" => array("type" => "text"),
1509                                                 ),
1510                                 "indexes" => array(
1511                                                 "PRIMARY" => array("id"),
1512                                                 )
1513                                 );
1514                 $database["search"] = array(
1515                                 "fields" => array(
1516                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1517                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1518                                                 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1519                                                 ),
1520                                 "indexes" => array(
1521                                                 "PRIMARY" => array("id"),
1522                                                 "uid" => array("uid"),
1523                                                 )
1524                                 );
1525                 $database["session"] = array(
1526                                 "fields" => array(
1527                                                 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1528                                                 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1529                                                 "data" => array("type" => "text"),
1530                                                 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1531                                                 ),
1532                                 "indexes" => array(
1533                                                 "PRIMARY" => array("id"),
1534                                                 "sid" => array("sid(64)"),
1535                                                 "expire" => array("expire"),
1536                                                 )
1537                                 );
1538                 $database["sign"] = array(
1539                                 "fields" => array(
1540                                                 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1541                                                 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1542                                                 "signed_text" => array("type" => "mediumtext"),
1543                                                 "signature" => array("type" => "text"),
1544                                                 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1545                                                 ),
1546                                 "indexes" => array(
1547                                                 "PRIMARY" => array("id"),
1548                                                 "iid" => array("UNIQUE", "iid"),
1549                                                 )
1550                                 );
1551                 $database["term"] = array(
1552                                 "fields" => array(
1553                                                 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1554                                                 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1555                                                 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1556                                                 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1557                                                 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1558                                                 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1559                                                 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1560                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1561                                                 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1562                                                 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1563                                                 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1564                                                 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1565                                                 ),
1566                                 "indexes" => array(
1567                                                 "PRIMARY" => array("tid"),
1568                                                 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1569                                                 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1570                                                 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1571                                                 "guid" => array("guid(64)"),
1572                                                 )
1573                                 );
1574                 $database["thread"] = array(
1575                                 "fields" => array(
1576                                                 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1577                                                 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1578                                                 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1579                                                 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1580                                                 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1581                                                 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1582                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1583                                                 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1584                                                 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1585                                                 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1586                                                 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1587                                                 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1588                                                 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1589                                                 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1590                                                 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1591                                                 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1592                                                 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1593                                                 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1594                                                 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1595                                                 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1596                                                 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1597                                                 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1598                                                 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1599                                                 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1600                                                 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1601                                                 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1602                                                 ),
1603                                 "indexes" => array(
1604                                                 "PRIMARY" => array("iid"),
1605                                                 "uid_network_commented" => array("uid","network","commented"),
1606                                                 "uid_network_created" => array("uid","network","created"),
1607                                                 "uid_contactid_commented" => array("uid","contact-id","commented"),
1608                                                 "uid_contactid_created" => array("uid","contact-id","created"),
1609                                                 "contactid" => array("contact-id"),
1610                                                 "ownerid" => array("owner-id"),
1611                                                 "authorid" => array("author-id"),
1612                                                 "uid_created" => array("uid","created"),
1613                                                 "uid_commented" => array("uid","commented"),
1614                                                 "uid_wall_created" => array("uid","wall","created"),
1615                                                 "private_wall_commented" => array("private","wall","commented"),
1616                                                 )
1617                                 );
1618                 $database["tokens"] = array(
1619                                 "fields" => array(
1620                                                 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1621                                                 "secret" => array("type" => "text"),
1622                                                 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1623                                                 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1624                                                 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1625                                                 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1626                                                 ),
1627                                 "indexes" => array(
1628                                                 "PRIMARY" => array("id"),
1629                                                 )
1630                                 );
1631                 $database["user"] = array(
1632                                 "fields" => array(
1633                                                 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1634                                                 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1635                                                 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1636                                                 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1637                                                 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1638                                                 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1639                                                 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1640                                                 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1641                                                 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1642                                                 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1643                                                 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1644                                                 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1645                                                 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1646                                                 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1647                                                 "pubkey" => array("type" => "text"),
1648                                                 "prvkey" => array("type" => "text"),
1649                                                 "spubkey" => array("type" => "text"),
1650                                                 "sprvkey" => array("type" => "text"),
1651                                                 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1652                                                 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1653                                                 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1654                                                 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1655                                                 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1656                                                 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1657                                                 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1658                                                 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1659                                                 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1660                                                 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1661                                                 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1662                                                 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1663                                                 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1664                                                 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1665                                                 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1666                                                 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1667                                                 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1668                                                 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1669                                                 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1670                                                 "allow_cid" => array("type" => "mediumtext"),
1671                                                 "allow_gid" => array("type" => "mediumtext"),
1672                                                 "deny_cid" => array("type" => "mediumtext"),
1673                                                 "deny_gid" => array("type" => "mediumtext"),
1674                                                 "openidserver" => array("type" => "text"),
1675                                                 ),
1676                                 "indexes" => array(
1677                                                 "PRIMARY" => array("uid"),
1678                                                 "nickname" => array("nickname(32)"),
1679                                                 )
1680                                 );
1681                 $database["userd"] = array(
1682                                 "fields" => array(
1683                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1684                                                 "username" => array("type" => "varchar(255)", "not null" => "1"),
1685                                                 ),
1686                                 "indexes" => array(
1687                                                 "PRIMARY" => array("id"),
1688                                                 "username" => array("username(32)"),
1689                                                 )
1690                                 );
1691                 $database["workerqueue"] = array(
1692                                 "fields" => array(
1693                                                 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1694                                                 "parameter" => array("type" => "text"),
1695                                                 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1696                                                 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1697                                                 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1698                                                 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1699                                                 "done" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1700                                                 ),
1701                                 "indexes" => array(
1702                                                 "PRIMARY" => array("id"),
1703                                                 "pid" => array("pid"),
1704                                                 "parameter" => array("parameter(64)"),
1705                                                 "priority_created" => array("priority", "created"),
1706                                                 "executed" => array("executed"),
1707                                                 )
1708                                 );
1709
1710                 return($database);
1711         }
1712 }