4 use Friendica\Core\Config;
6 require_once "boot.php";
7 require_once "include/text.php";
9 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
12 * Converts all tables from MyISAM to InnoDB
14 function convert_to_innodb() {
17 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
18 dbesc($db->database_name()));
20 if (!dbm::is_result($r)) {
21 echo t('There are no tables on MyISAM.')."\n";
25 foreach ($r AS $table) {
26 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
29 $result = @$db->q($sql);
30 if (!dbm::is_result($result)) {
31 print_update_error($db, $sql);
37 * send the email and do what is needed to do on update fails
39 * @param update_id (int) number of failed update
40 * @param error_message (str) error message
42 function update_fail($update_id, $error_message) {
43 //send the administrators an e-mail
44 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
45 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
50 if (!dbm::is_result($adminlist)) {
51 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
57 // every admin could had different language
58 foreach ($adminlist as $admin) {
59 $lang = (($admin['language'])?$admin['language']:'en');
62 $preamble = deindent(t("
63 The friendica developers released update %s recently,
64 but when I tried to install it, something went terribly wrong.
65 This needs to be fixed soon and I can't do it alone. Please contact a
66 friendica developer if you can not help me on your own. My database might be invalid."));
67 $body = t("The error message is\n[pre]%s[/pre]");
68 $preamble = sprintf($preamble, $update_id);
69 $body = sprintf($body, $error_message);
72 'type' => "SYSTEM_EMAIL",
73 'to_email' => $admin['email'],
74 'preamble' => $preamble,
84 $email_tpl = get_intltext_template("update_fail_eml.tpl");
85 $email_msg = replace_macros($email_tpl, array(
86 '$sitename' => $a->config['sitename'],
87 '$siteurl' => App::get_baseurl(),
88 '$update' => DB_UPDATE_VERSION,
89 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
91 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
92 require_once('include/email.php');
93 $subject = email_header_encode($subject,'UTF-8');
94 mail($a->config['admin_email'], $subject, $email_msg,
95 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
96 .'Content-type: text/plain; charset=UTF-8'."\n"
97 .'Content-transfer-encoding: 8bit');
100 logger("CRITICAL: Database structure update failed: ".$retval);
104 function table_structure($table) {
105 $structures = q("DESCRIBE `%s`", $table);
107 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
109 $indexes = q("SHOW INDEX FROM `%s`", $table);
111 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
113 if (dbm::is_result($table_status)) {
114 $table_status = $table_status[0];
116 $table_status = array();
119 $fielddata = array();
120 $indexdata = array();
122 if (dbm::is_result($indexes))
123 foreach ($indexes AS $index) {
124 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
125 $indexdata[$index["Key_name"]] = array('UNIQUE');
128 $column = $index["Column_name"];
129 // On utf8mb4 a varchar index can only have a length of 191
130 // The "show index" command sometimes returns this value although this value wasn't added manually.
131 // Because we don't want to add this number to every index, we ignore bigger numbers
132 if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 191) OR ($index["Key_name"] == "PRIMARY"))) {
133 $column .= "(".$index["Sub_part"].")";
136 $indexdata[$index["Key_name"]][] = $column;
138 if (dbm::is_result($structures)) {
139 foreach ($structures AS $field) {
140 $fielddata[$field["Field"]]["type"] = $field["Type"];
141 if ($field["Null"] == "NO") {
142 $fielddata[$field["Field"]]["not null"] = true;
145 if (isset($field["Default"])) {
146 $fielddata[$field["Field"]]["default"] = $field["Default"];
149 if ($field["Extra"] != "") {
150 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
153 if ($field["Key"] == "PRI") {
154 $fielddata[$field["Field"]]["primary"] = true;
158 if (dbm::is_result($full_columns)) {
159 foreach ($full_columns AS $column) {
160 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
164 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
167 function print_structure($database) {
168 echo "-- ------------------------------------------\n";
169 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
170 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
171 echo "-- ------------------------------------------\n\n\n";
172 foreach ($database AS $name => $structure) {
174 echo "-- TABLE $name\n";
176 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
183 * @brief Print out database error messages
185 * @param object $db Database object
186 * @param string $message Message to be added to the error message
188 * @return string Error message
190 function print_update_error($db, $message) {
191 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
192 $db->errorno, $db->error);
194 return t('Errors encountered performing database changes: ').$message.EOL;
197 function update_structure($verbose, $action, $tables=null, $definition=null) {
201 Config::set('system', 'maintenance', 1);
202 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
207 logger('updating structure', LOGGER_DEBUG);
209 // Get the current structure
212 if (is_null($tables)) {
213 $tables = q("SHOW TABLES");
216 if (dbm::is_result($tables)) {
217 foreach ($tables AS $table) {
218 $table = current($table);
220 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
221 $database[$table] = table_structure($table);
225 // Get the definition
226 if (is_null($definition)) {
227 $definition = db_definition();
230 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
231 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
232 !(strpos($db->server_info(), 'MariaDB') !== false)) {
239 foreach ($definition AS $name => $structure) {
240 $is_new_table = False;
243 if (!isset($database[$name])) {
244 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
245 if (!dbm::is_result($r)) {
246 $errors .= print_update_error($db, $name);
248 $is_new_table = True;
253 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
254 if (isset($database[$name]["indexes"][$indexname])) {
255 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
257 $current_index_definition = "__NOT_SET__";
259 $new_index_definition = implode(",",$fieldnames);
260 if ($current_index_definition != $new_index_definition) {
261 if ($fieldnames[0] == "UNIQUE") {
264 $temp_name = "temp-".$name;
271 * Drop the index if it isn't present in the definition
272 * or the definition differ from current status
273 * and index name doesn't start with "local_"
275 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
276 $current_index_definition = implode(",",$fieldnames);
277 if (isset($structure["indexes"][$indexname])) {
278 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
280 $new_index_definition = "__NOT_SET__";
282 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
283 $sql2=db_drop_index($indexname);
285 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
291 // Compare the field structure field by field
292 foreach ($structure["fields"] AS $fieldname => $parameters) {
293 if (!isset($database[$name]["fields"][$fieldname])) {
294 $sql2=db_add_table_field($fieldname, $parameters);
296 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
301 // Compare the field definition
302 $field_definition = $database[$name]["fields"][$fieldname];
304 // Remove the relation data that is used for the referential integrity
305 unset($parameters['relation']);
307 // We change the collation after the indexes had been changed.
308 // This is done to avoid index length problems.
309 // So here we always ensure that there is no need to change it.
310 unset($parameters['Collation']);
311 unset($field_definition['Collation']);
313 $current_field_definition = implode(",", $field_definition);
314 $new_field_definition = implode(",", $parameters);
315 if ($current_field_definition != $new_field_definition) {
316 $sql2 = db_modify_table_field($fieldname, $parameters);
318 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
328 * Create the index if the index don't exists in database
329 * or the definition differ from the current status.
330 * Don't create keys if table is new
332 if (!$is_new_table) {
333 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
334 if (isset($database[$name]["indexes"][$indexname])) {
335 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
337 $current_index_definition = "__NOT_SET__";
339 $new_index_definition = implode(",",$fieldnames);
340 if ($current_index_definition != $new_index_definition) {
341 $sql2 = db_create_index($indexname, $fieldnames);
343 // Fetch the "group by" fields for unique indexes
344 if ($fieldnames[0] == "UNIQUE") {
345 $group_by = db_group_by($indexname, $fieldnames);
349 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
357 if (isset($database[$name]["table_status"]["Collation"])) {
358 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
359 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
362 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
373 // Now have a look at the field collations
374 // Compare the field structure field by field
375 foreach ($structure["fields"] AS $fieldname => $parameters) {
376 // Compare the field definition
377 $field_definition = $database[$name]["fields"][$fieldname];
379 // Define the default collation if not given
380 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
381 $parameters['Collation'] = 'utf8mb4_general_ci';
383 $parameters['Collation'] = null;
386 if ($field_definition['Collation'] != $parameters['Collation']) {
387 $sql2 = db_modify_table_field($fieldname, $parameters);
388 if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
389 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
398 if (substr($sql3, -2, 2) != "; ") {
403 if ($is_unique && $ignore == '') {
404 foreach ($structure['fields'] AS $fieldname => $parameters) {
405 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
407 $field_list = rtrim($field_list, ',');
411 // Ensure index conversion to unique removes duplicates
414 echo "SET session old_alter_table=1;\n";
416 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
424 echo "SET session old_alter_table=0;\n";
426 echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
427 echo "DROP TABLE `".$name."`;\n";
428 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
434 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
436 // Ensure index conversion to unique removes duplicates
439 $db->q("SET session old_alter_table=1;");
441 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
442 if (!dbm::is_result($r)) {
443 $errors .= print_update_error($db, $sql3);
450 if (!dbm::is_result($r)) {
451 $errors .= print_update_error($db, $sql3);
455 $db->q("SET session old_alter_table=0;");
457 $r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
458 if (!dbm::is_result($r)) {
459 $errors .= print_update_error($db, $sql3);
462 $r = $db->q("DROP TABLE `".$name."`;");
463 if (!dbm::is_result($r)) {
464 $errors .= print_update_error($db, $sql3);
467 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
468 if (!dbm::is_result($r)) {
469 $errors .= print_update_error($db, $sql3);
479 Config::set('system', 'maintenance', 0);
480 Config::set('system', 'maintenance_reason', '');
486 function db_field_command($parameters, $create = true) {
487 $fieldstruct = $parameters["type"];
489 if (!is_null($parameters["Collation"])) {
490 $fieldstruct .= " COLLATE ".$parameters["Collation"];
493 if ($parameters["not null"])
494 $fieldstruct .= " NOT NULL";
496 if (isset($parameters["default"])) {
497 if (strpos(strtolower($parameters["type"]),"int")!==false) {
498 $fieldstruct .= " DEFAULT ".$parameters["default"];
500 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
503 if ($parameters["extra"] != "")
504 $fieldstruct .= " ".$parameters["extra"];
506 /*if (($parameters["primary"] != "") AND $create)
507 $fieldstruct .= " PRIMARY KEY";*/
509 return($fieldstruct);
512 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
520 $primary_keys = array();
521 foreach ($fields AS $fieldname => $field) {
522 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
523 if (x($field,'primary') and $field['primary']!='') {
524 $primary_keys[] = $fieldname;
528 if (!is_null($indexes)) {
529 foreach ($indexes AS $indexname => $fieldnames) {
530 $sql_index = db_create_index($indexname, $fieldnames, "");
531 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
535 $sql = implode(",\n\t", $sql_rows);
537 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
547 function db_add_table_field($fieldname, $parameters) {
548 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
552 function db_modify_table_field($fieldname, $parameters) {
553 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
557 function db_drop_index($indexname) {
558 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
562 function db_create_index($indexname, $fieldnames, $method="ADD") {
564 $method = strtoupper(trim($method));
565 if ($method!="" && $method!="ADD") {
566 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
570 if ($fieldnames[0] == "UNIQUE") {
571 array_shift($fieldnames);
572 $method .= ' UNIQUE';
576 foreach ($fieldnames AS $fieldname) {
580 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
581 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
583 $names .= "`".dbesc($fieldname)."`";
587 if ($indexname == "PRIMARY") {
588 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
592 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
596 function db_group_by($indexname, $fieldnames) {
598 if ($fieldnames[0] != "UNIQUE") {
602 array_shift($fieldnames);
605 foreach ($fieldnames AS $fieldname) {
609 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
610 $names .= "`".dbesc($matches[1])."`";
612 $names .= "`".dbesc($fieldname)."`";
616 $sql = sprintf(" GROUP BY %s", $names);
620 function db_definition() {
624 $database["addon"] = array(
626 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
627 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
628 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
629 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
630 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
631 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
632 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
635 "PRIMARY" => array("id"),
636 "name" => array("UNIQUE", "name"),
639 $database["attach"] = array(
641 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
642 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
643 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
644 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
645 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
646 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
647 "data" => array("type" => "longblob", "not null" => "1"),
648 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
649 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
650 "allow_cid" => array("type" => "mediumtext"),
651 "allow_gid" => array("type" => "mediumtext"),
652 "deny_cid" => array("type" => "mediumtext"),
653 "deny_gid" => array("type" => "mediumtext"),
656 "PRIMARY" => array("id"),
659 $database["auth_codes"] = array(
661 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
662 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
663 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
664 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
665 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
668 "PRIMARY" => array("id"),
671 $database["cache"] = array(
673 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
674 "v" => array("type" => "mediumtext"),
675 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
676 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
679 "PRIMARY" => array("k"),
680 "expire_mode_updated" => array("expire_mode", "updated"),
683 $database["challenge"] = array(
685 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
686 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
687 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
688 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
689 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
690 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
693 "PRIMARY" => array("id"),
696 $database["clients"] = array(
698 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
699 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
700 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
701 "name" => array("type" => "text"),
702 "icon" => array("type" => "text"),
703 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
706 "PRIMARY" => array("client_id"),
709 $database["config"] = array(
711 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
712 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
713 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
714 "v" => array("type" => "mediumtext"),
717 "PRIMARY" => array("id"),
718 "cat_k" => array("UNIQUE", "cat", "k"),
721 $database["contact"] = array(
723 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
724 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
725 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
726 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
727 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
728 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
729 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
730 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "about" => array("type" => "text"),
735 "keywords" => array("type" => "text"),
736 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
737 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "photo" => array("type" => "text"),
741 "thumb" => array("type" => "text"),
742 "micro" => array("type" => "text"),
743 "site-pubkey" => array("type" => "text"),
744 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "pubkey" => array("type" => "text"),
751 "prvkey" => array("type" => "text"),
752 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
753 "request" => array("type" => "text"),
754 "notify" => array("type" => "text"),
755 "poll" => array("type" => "text"),
756 "confirm" => array("type" => "text"),
757 "poco" => array("type" => "text"),
758 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
759 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
760 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
761 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
762 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
763 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
764 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
765 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
766 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
767 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
768 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
769 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
770 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
771 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
772 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
773 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
775 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
776 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
777 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
778 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
779 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
780 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
781 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782 "reason" => array("type" => "text"),
783 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
784 "info" => array("type" => "mediumtext"),
785 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
786 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
787 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
788 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
790 "ffi_keyword_blacklist" => array("type" => "text"),
793 "PRIMARY" => array("id"),
794 "uid_name" => array("uid", "name(190)"),
795 "self_uid" => array("self", "uid"),
796 "alias_uid" => array("alias(32)", "uid"),
797 "pending_uid" => array("pending", "uid"),
798 "blocked_uid" => array("blocked", "uid"),
799 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
800 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
801 "addr_uid" => array("addr(32)", "uid"),
802 "nurl_uid" => array("nurl(32)", "uid"),
803 "nick_uid" => array("nick(32)", "uid"),
804 "dfrn-id" => array("dfrn-id"),
805 "issued-id" => array("issued-id"),
808 $database["conv"] = array(
810 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
811 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
812 "recips" => array("type" => "text"),
813 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
814 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
815 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
816 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
817 "subject" => array("type" => "text"),
820 "PRIMARY" => array("id"),
821 "uid" => array("uid"),
824 $database["conversation"] = array(
826 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
827 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
828 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
829 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
830 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
831 "source" => array("type" => "mediumtext"),
832 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
835 "PRIMARY" => array("item-uri"),
836 "conversation-uri" => array("conversation-uri"),
839 $database["event"] = array(
841 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
842 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
843 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
844 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
845 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
846 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
847 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
848 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
849 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
850 "summary" => array("type" => "text"),
851 "desc" => array("type" => "text"),
852 "location" => array("type" => "text"),
853 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
854 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
855 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
856 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
857 "allow_cid" => array("type" => "mediumtext"),
858 "allow_gid" => array("type" => "mediumtext"),
859 "deny_cid" => array("type" => "mediumtext"),
860 "deny_gid" => array("type" => "mediumtext"),
863 "PRIMARY" => array("id"),
864 "uid_start" => array("uid", "start"),
867 $database["fcontact"] = array(
869 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
870 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
872 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
873 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
875 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
877 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
878 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
879 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
880 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
881 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
882 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
883 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884 "pubkey" => array("type" => "text"),
885 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
888 "PRIMARY" => array("id"),
889 "addr" => array("addr(32)"),
890 "url" => array("UNIQUE", "url(190)"),
893 $database["ffinder"] = array(
895 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
896 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
897 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
898 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
901 "PRIMARY" => array("id"),
904 $database["fserver"] = array(
906 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
907 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
908 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
909 "key" => array("type" => "text"),
912 "PRIMARY" => array("id"),
913 "server" => array("server(32)"),
916 $database["fsuggest"] = array(
918 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
919 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
920 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
921 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
922 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
923 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
924 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
925 "note" => array("type" => "text"),
926 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
929 "PRIMARY" => array("id"),
932 $database["gcign"] = array(
934 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
935 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
936 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
939 "PRIMARY" => array("id"),
940 "uid" => array("uid"),
941 "gcid" => array("gcid"),
944 $database["gcontact"] = array(
946 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
947 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
948 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
949 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
950 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
951 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
952 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
953 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
954 "updated" => array("type" => "datetime", "default" => NULL_DATE),
955 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
956 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
957 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "about" => array("type" => "text"),
959 "keywords" => array("type" => "text"),
960 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
961 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
962 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
963 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
964 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
965 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
966 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
967 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
968 "notify" => array("type" => "text"),
969 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
970 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
971 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
974 "PRIMARY" => array("id"),
975 "nurl" => array("UNIQUE", "nurl(190)"),
976 "name" => array("name(64)"),
977 "nick" => array("nick(32)"),
978 "addr" => array("addr(64)"),
979 "hide_network_updated" => array("hide", "network(4)", "updated"),
980 "updated" => array("updated"),
983 $database["glink"] = array(
985 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
986 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
987 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
988 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
989 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
990 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
993 "PRIMARY" => array("id"),
994 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
995 "gcid" => array("gcid"),
998 $database["group"] = array(
1000 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1001 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1002 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1003 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1004 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1007 "PRIMARY" => array("id"),
1008 "uid" => array("uid"),
1011 $database["group_member"] = array(
1013 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1014 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1015 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1016 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1019 "PRIMARY" => array("id"),
1020 "contactid" => array("contact-id"),
1021 "gid_contactid" => array("gid", "contact-id"),
1022 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1025 $database["gserver"] = array(
1027 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1028 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1029 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1030 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1031 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1032 "info" => array("type" => "text"),
1033 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1034 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1036 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1037 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1039 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1040 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1041 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1044 "PRIMARY" => array("id"),
1045 "nurl" => array("UNIQUE", "nurl(190)"),
1048 $database["hook"] = array(
1050 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1051 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1052 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1053 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1054 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1057 "PRIMARY" => array("id"),
1058 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1061 $database["intro"] = array(
1063 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1064 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1065 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1066 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1067 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1068 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1069 "note" => array("type" => "text"),
1070 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1071 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1072 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1073 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1076 "PRIMARY" => array("id"),
1079 $database["item"] = array(
1081 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1082 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1083 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1084 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1085 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1086 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1087 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1088 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1089 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1090 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1091 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1092 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1095 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1096 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1097 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1098 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1099 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1100 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1101 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1102 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1104 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1107 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1108 "body" => array("type" => "mediumtext"),
1109 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1110 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1111 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1112 "object" => array("type" => "text"),
1113 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1114 "target" => array("type" => "text"),
1115 "postopts" => array("type" => "text"),
1116 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1118 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1119 "tag" => array("type" => "mediumtext"),
1120 "attach" => array("type" => "mediumtext"),
1121 "inform" => array("type" => "mediumtext"),
1122 "file" => array("type" => "mediumtext"),
1123 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1124 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1125 "allow_cid" => array("type" => "mediumtext"),
1126 "allow_gid" => array("type" => "mediumtext"),
1127 "deny_cid" => array("type" => "mediumtext"),
1128 "deny_gid" => array("type" => "mediumtext"),
1129 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1130 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1131 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1132 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1133 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1134 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1135 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1136 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1137 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1138 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1139 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1140 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1141 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1142 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1143 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1144 "rendered-html" => array("type" => "mediumtext"),
1145 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1148 "PRIMARY" => array("id"),
1149 "guid" => array("guid"),
1150 "uri" => array("uri"),
1151 "parent" => array("parent"),
1152 "parent-uri" => array("parent-uri"),
1153 "extid" => array("extid"),
1154 "uid_id" => array("uid","id"),
1155 "uid_contactid_id" => array("uid","contact-id","id"),
1156 "uid_created" => array("uid","created"),
1157 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1158 "uid_network_received" => array("uid","network(4)","received"),
1159 "uid_network_commented" => array("uid","network(4)","commented"),
1160 "uid_thrparent" => array("uid","thr-parent(190)"),
1161 "uid_parenturi" => array("uid","parent-uri(190)"),
1162 "uid_contactid_created" => array("uid","contact-id","created"),
1163 "authorid_created" => array("author-id","created"),
1164 "ownerid" => array("owner-id"),
1165 "uid_uri" => array("uid", "uri(190)"),
1166 "resource-id" => array("resource-id"),
1167 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1168 "uid_type_changed" => array("uid","type(190)","changed"),
1169 "contactid_verb" => array("contact-id","verb(190)"),
1170 "deleted_changed" => array("deleted","changed"),
1171 "uid_wall_changed" => array("uid","wall","changed"),
1172 "uid_eventid" => array("uid","event-id"),
1173 "uid_authorlink" => array("uid","author-link(190)"),
1174 "uid_ownerlink" => array("uid","owner-link(190)"),
1177 $database["item_id"] = array(
1179 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1180 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1181 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1182 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1183 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1186 "PRIMARY" => array("id"),
1187 "uid" => array("uid"),
1188 "sid" => array("sid"),
1189 "service" => array("service(32)"),
1190 "iid" => array("iid"),
1193 $database["locks"] = array(
1195 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1196 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1197 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1198 "created" => array("type" => "datetime", "default" => NULL_DATE),
1201 "PRIMARY" => array("id"),
1204 $database["mail"] = array(
1206 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1207 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1208 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1209 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1210 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1211 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1212 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1213 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1214 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1215 "body" => array("type" => "mediumtext"),
1216 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1217 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1218 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1219 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1220 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1221 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1222 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1225 "PRIMARY" => array("id"),
1226 "uid_seen" => array("uid", "seen"),
1227 "convid" => array("convid"),
1228 "uri" => array("uri(64)"),
1229 "parent-uri" => array("parent-uri(64)"),
1230 "contactid" => array("contact-id"),
1233 $database["mailacct"] = array(
1235 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1236 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1237 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1238 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1239 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1240 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1241 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1242 "pass" => array("type" => "text"),
1243 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1244 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1245 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1246 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1247 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1250 "PRIMARY" => array("id"),
1253 $database["manage"] = array(
1255 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1256 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1257 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1260 "PRIMARY" => array("id"),
1261 "uid_mid" => array("UNIQUE", "uid","mid"),
1264 $database["notify"] = array(
1266 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1267 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1268 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1269 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1270 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1271 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1272 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1273 "msg" => array("type" => "mediumtext"),
1274 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1275 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1276 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1277 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1278 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1279 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1280 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1281 "name_cache" => array("type" => "tinytext"),
1282 "msg_cache" => array("type" => "mediumtext")
1285 "PRIMARY" => array("id"),
1286 "hash_uid" => array("hash", "uid"),
1287 "seen_uid_date" => array("seen", "uid", "date"),
1288 "uid_date" => array("uid", "date"),
1289 "uid_type_link" => array("uid", "type", "link(190)"),
1292 $database["notify-threads"] = array(
1294 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1295 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1296 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1297 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1298 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1301 "PRIMARY" => array("id"),
1304 $database["oembed"] = array(
1306 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1307 "content" => array("type" => "mediumtext"),
1308 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1311 "PRIMARY" => array("url"),
1312 "created" => array("created"),
1315 $database["parsed_url"] = array(
1317 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1318 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1319 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1320 "content" => array("type" => "mediumtext"),
1321 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1324 "PRIMARY" => array("url", "guessing", "oembed"),
1325 "created" => array("created"),
1328 $database["pconfig"] = array(
1330 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1331 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1332 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1333 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1334 "v" => array("type" => "mediumtext"),
1337 "PRIMARY" => array("id"),
1338 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1341 $database["photo"] = array(
1343 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1344 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1345 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1346 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1347 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1348 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1349 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1350 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1351 "desc" => array("type" => "text"),
1352 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1353 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1354 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1355 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1356 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1357 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1358 "data" => array("type" => "mediumblob", "not null" => "1"),
1359 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1360 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1361 "allow_cid" => array("type" => "mediumtext"),
1362 "allow_gid" => array("type" => "mediumtext"),
1363 "deny_cid" => array("type" => "mediumtext"),
1364 "deny_gid" => array("type" => "mediumtext"),
1367 "PRIMARY" => array("id"),
1368 "contactid" => array("contact-id"),
1369 "uid_contactid" => array("uid", "contact-id"),
1370 "uid_profile" => array("uid", "profile"),
1371 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1372 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1373 "resource-id" => array("resource-id(64)"),
1376 $database["poll"] = array(
1378 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1379 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1380 "q0" => array("type" => "text"),
1381 "q1" => array("type" => "text"),
1382 "q2" => array("type" => "text"),
1383 "q3" => array("type" => "text"),
1384 "q4" => array("type" => "text"),
1385 "q5" => array("type" => "text"),
1386 "q6" => array("type" => "text"),
1387 "q7" => array("type" => "text"),
1388 "q8" => array("type" => "text"),
1389 "q9" => array("type" => "text"),
1392 "PRIMARY" => array("id"),
1393 "uid" => array("uid"),
1396 $database["poll_result"] = array(
1398 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1399 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1400 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1403 "PRIMARY" => array("id"),
1404 "poll_id" => array("poll_id"),
1405 "choice" => array("choice"),
1408 $database["process"] = array(
1410 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1411 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1412 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1415 "PRIMARY" => array("pid"),
1416 "command" => array("command"),
1419 $database["profile"] = array(
1421 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1422 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1423 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1424 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1425 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1426 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1427 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1428 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1429 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1430 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1431 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1432 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1433 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1434 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1435 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1436 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1437 "with" => array("type" => "text"),
1438 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1439 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1440 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1441 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1442 "pub_keywords" => array("type" => "text"),
1443 "prv_keywords" => array("type" => "text"),
1444 "likes" => array("type" => "text"),
1445 "dislikes" => array("type" => "text"),
1446 "about" => array("type" => "text"),
1447 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1448 "music" => array("type" => "text"),
1449 "book" => array("type" => "text"),
1450 "tv" => array("type" => "text"),
1451 "film" => array("type" => "text"),
1452 "interest" => array("type" => "text"),
1453 "romance" => array("type" => "text"),
1454 "work" => array("type" => "text"),
1455 "education" => array("type" => "text"),
1456 "contact" => array("type" => "text"),
1457 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1458 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1459 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1460 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1461 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1462 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1465 "PRIMARY" => array("id"),
1466 "uid_is-default" => array("uid", "is-default"),
1469 $database["profile_check"] = array(
1471 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1472 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1473 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1474 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1475 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1476 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1479 "PRIMARY" => array("id"),
1482 $database["push_subscriber"] = array(
1484 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1485 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1486 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1487 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1488 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1489 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1490 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1491 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1494 "PRIMARY" => array("id"),
1497 $database["queue"] = array(
1499 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1500 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1501 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1502 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1503 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1504 "content" => array("type" => "mediumtext"),
1505 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1508 "PRIMARY" => array("id"),
1509 "cid" => array("cid"),
1510 "created" => array("created"),
1511 "last" => array("last"),
1512 "network" => array("network"),
1513 "batch" => array("batch"),
1516 $database["register"] = array(
1518 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1519 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1520 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1521 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1522 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1523 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1524 "note" => array("type" => "text"),
1527 "PRIMARY" => array("id"),
1530 $database["search"] = array(
1532 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1533 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1534 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1537 "PRIMARY" => array("id"),
1538 "uid" => array("uid"),
1541 $database["session"] = array(
1543 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1544 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1545 "data" => array("type" => "text"),
1546 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1549 "PRIMARY" => array("id"),
1550 "sid" => array("sid(64)"),
1551 "expire" => array("expire"),
1554 $database["sign"] = array(
1556 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1557 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1558 "signed_text" => array("type" => "mediumtext"),
1559 "signature" => array("type" => "text"),
1560 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1563 "PRIMARY" => array("id"),
1564 "iid" => array("iid"),
1567 $database["spam"] = array(
1569 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1570 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1571 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1572 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1573 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1574 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1577 "PRIMARY" => array("id"),
1578 "uid" => array("uid"),
1579 "spam" => array("spam"),
1580 "ham" => array("ham"),
1581 "term" => array("term"),
1584 $database["term"] = array(
1586 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1587 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1588 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1589 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1590 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1591 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1592 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1593 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1594 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1595 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1596 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1597 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1600 "PRIMARY" => array("tid"),
1601 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1602 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1603 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1604 "guid" => array("guid(64)"),
1607 $database["thread"] = array(
1609 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1610 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1611 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1612 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1613 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1614 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1615 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1616 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1617 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1618 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1619 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1620 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1621 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1622 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1623 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1624 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1625 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1626 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1627 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1628 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1629 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1630 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1631 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1632 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1633 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1634 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1637 "PRIMARY" => array("iid"),
1638 "uid_network_commented" => array("uid","network","commented"),
1639 "uid_network_created" => array("uid","network","created"),
1640 "uid_contactid_commented" => array("uid","contact-id","commented"),
1641 "uid_contactid_created" => array("uid","contact-id","created"),
1642 "contactid" => array("contact-id"),
1643 "ownerid" => array("owner-id"),
1644 "authorid" => array("author-id"),
1645 "uid_created" => array("uid","created"),
1646 "uid_commented" => array("uid","commented"),
1647 "uid_wall_created" => array("uid","wall","created"),
1650 $database["tokens"] = array(
1652 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1653 "secret" => array("type" => "text"),
1654 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1655 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1656 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1657 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1660 "PRIMARY" => array("id"),
1663 $database["user"] = array(
1665 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1666 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1667 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1668 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1669 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1670 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1671 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1672 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1673 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1674 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1675 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1676 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1677 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1678 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1679 "pubkey" => array("type" => "text"),
1680 "prvkey" => array("type" => "text"),
1681 "spubkey" => array("type" => "text"),
1682 "sprvkey" => array("type" => "text"),
1683 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1684 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1685 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1686 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1687 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1688 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1689 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1690 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1691 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1692 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1693 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1694 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1695 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1696 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1697 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1698 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1699 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1700 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1701 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1702 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1703 "allow_cid" => array("type" => "mediumtext"),
1704 "allow_gid" => array("type" => "mediumtext"),
1705 "deny_cid" => array("type" => "mediumtext"),
1706 "deny_gid" => array("type" => "mediumtext"),
1707 "openidserver" => array("type" => "text"),
1710 "PRIMARY" => array("uid"),
1711 "nickname" => array("nickname(32)"),
1714 $database["userd"] = array(
1716 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1717 "username" => array("type" => "varchar(255)", "not null" => "1"),
1720 "PRIMARY" => array("id"),
1721 "username" => array("username(32)"),
1724 $database["workerqueue"] = array(
1726 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1727 "parameter" => array("type" => "text"),
1728 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1729 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1730 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1731 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1734 "PRIMARY" => array("id"),
1743 * run from command line
1745 function dbstructure_run(&$argv, &$argc) {
1749 $a = new App(dirname(__DIR__));
1753 @include(".htconfig.php");
1754 require_once("include/dba.php");
1755 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1756 unset($db_host, $db_user, $db_pass, $db_data);
1762 update_structure(true, false);
1765 update_structure(true, true);
1767 $build = get_config('system','build');
1769 set_config('system', 'build', DB_UPDATE_VERSION);
1770 $build = DB_UPDATE_VERSION;
1773 $stored = intval($build);
1774 $current = intval(DB_UPDATE_VERSION);
1776 // run any left update_nnnn functions in update.php
1777 for ($x = $stored; $x < $current; $x ++) {
1778 $r = run_update_function($x);
1784 set_config('system','build',DB_UPDATE_VERSION);
1787 print_structure(db_definition());
1790 convert_to_innodb();
1797 echo $argv[0]." <command>\n";
1800 echo "dryrun show database update schema queries without running them\n";
1801 echo "update update database schema\n";
1802 echo "dumpsql dump database schema\n";
1803 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1808 if (array_search(__FILE__,get_included_files())===0) {
1809 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);