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