4 use Friendica\Core\System;
5 use Friendica\Core\Config;
7 require_once "boot.php";
8 require_once "include/text.php";
10 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
12 const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before
13 const DB_UPDATE_SUCCESSFUL = 1; // Database check was successful
14 const DB_UPDATE_FAILED = 2; // Database check failed
17 * Converts all tables from MyISAM to InnoDB
19 function convert_to_innodb() {
22 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
23 dbesc($db->database_name()));
25 if (!dbm::is_result($r)) {
26 echo t('There are no tables on MyISAM.')."\n";
30 foreach ($r AS $table) {
31 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
34 $result = $db->q($sql);
35 if (!dbm::is_result($result)) {
36 print_update_error($db, $sql);
42 * send the email and do what is needed to do on update fails
44 * @param update_id (int) number of failed update
45 * @param error_message (str) error message
47 function update_fail($update_id, $error_message) {
48 //send the administrators an e-mail
49 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
50 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
55 if (!dbm::is_result($adminlist)) {
56 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
62 // every admin could had different language
63 foreach ($adminlist as $admin) {
64 $lang = (($admin['language'])?$admin['language']:'en');
67 $preamble = deindent(t("
68 The friendica developers released update %s recently,
69 but when I tried to install it, something went terribly wrong.
70 This needs to be fixed soon and I can't do it alone. Please contact a
71 friendica developer if you can not help me on your own. My database might be invalid."));
72 $body = t("The error message is\n[pre]%s[/pre]");
73 $preamble = sprintf($preamble, $update_id);
74 $body = sprintf($body, $error_message);
77 'type' => "SYSTEM_EMAIL",
78 'to_email' => $admin['email'],
79 'preamble' => $preamble,
89 @TODO deprecated code?
90 $email_tpl = get_intltext_template("update_fail_eml.tpl");
91 $email_msg = replace_macros($email_tpl, array(
92 '$sitename' => $a->config['sitename'],
93 '$siteurl' => App::get_baseurl(),
94 '$update' => DB_UPDATE_VERSION,
95 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
97 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
98 require_once('include/email.php');
99 $subject = email_header_encode($subject,'UTF-8');
100 mail($a->config['admin_email'], $subject, $email_msg,
101 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
102 .'Content-type: text/plain; charset=UTF-8'."\n"
103 .'Content-transfer-encoding: 8bit');
106 logger("CRITICAL: Database structure update failed: ".$retval);
110 function table_structure($table) {
111 $structures = q("DESCRIBE `%s`", $table);
113 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
115 $indexes = q("SHOW INDEX FROM `%s`", $table);
117 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
119 if (dbm::is_result($table_status)) {
120 $table_status = $table_status[0];
122 $table_status = array();
125 $fielddata = array();
126 $indexdata = array();
128 if (dbm::is_result($indexes))
129 foreach ($indexes AS $index) {
130 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
131 $indexdata[$index["Key_name"]] = array('UNIQUE');
134 $column = $index["Column_name"];
135 // On utf8mb4 a varchar index can only have a length of 191
136 // The "show index" command sometimes returns this value although this value wasn't added manually.
137 // Because we don't want to add this number to every index, we ignore bigger numbers
138 if (($index["Sub_part"] != "") && (($index["Sub_part"] < 191) || ($index["Key_name"] == "PRIMARY"))) {
139 $column .= "(".$index["Sub_part"].")";
142 $indexdata[$index["Key_name"]][] = $column;
144 if (dbm::is_result($structures)) {
145 foreach ($structures AS $field) {
146 $fielddata[$field["Field"]]["type"] = $field["Type"];
147 if ($field["Null"] == "NO") {
148 $fielddata[$field["Field"]]["not null"] = true;
151 if (isset($field["Default"])) {
152 $fielddata[$field["Field"]]["default"] = $field["Default"];
155 if ($field["Extra"] != "") {
156 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
159 if ($field["Key"] == "PRI") {
160 $fielddata[$field["Field"]]["primary"] = true;
164 if (dbm::is_result($full_columns)) {
165 foreach ($full_columns AS $column) {
166 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
170 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
173 function print_structure($database) {
174 echo "-- ------------------------------------------\n";
175 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
176 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
177 echo "-- ------------------------------------------\n\n\n";
178 foreach ($database AS $name => $structure) {
180 echo "-- TABLE $name\n";
182 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
189 * @brief Print out database error messages
191 * @param object $db Database object
192 * @param string $message Message to be added to the error message
194 * @return string Error message
196 function print_update_error($db, $message) {
197 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
198 $db->errorno, $db->error);
200 return t('Errors encountered performing database changes: ').$message.EOL;
203 function update_structure($verbose, $action, $tables=null, $definition=null) {
207 Config::set('system', 'maintenance', 1);
208 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
213 logger('updating structure', LOGGER_DEBUG);
215 // Get the current structure
218 if (is_null($tables)) {
219 $tables = q("SHOW TABLES");
222 if (dbm::is_result($tables)) {
223 foreach ($tables AS $table) {
224 $table = current($table);
226 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
227 $database[$table] = table_structure($table);
231 // Get the definition
232 if (is_null($definition)) {
233 $definition = db_definition();
236 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
237 if ((version_compare($db->server_info(), '5.7.4') >= 0) &&
238 !(strpos($db->server_info(), 'MariaDB') !== false)) {
245 foreach ($definition AS $name => $structure) {
246 $is_new_table = False;
249 if (!isset($database[$name])) {
250 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
251 if (!dbm::is_result($r)) {
252 $errors .= print_update_error($db, $name);
254 $is_new_table = True;
259 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
260 if (isset($database[$name]["indexes"][$indexname])) {
261 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
263 $current_index_definition = "__NOT_SET__";
265 $new_index_definition = implode(",",$fieldnames);
266 if ($current_index_definition != $new_index_definition) {
267 if ($fieldnames[0] == "UNIQUE") {
270 $temp_name = "temp-".$name;
277 * Drop the index if it isn't present in the definition
278 * or the definition differ from current status
279 * and index name doesn't start with "local_"
281 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
282 $current_index_definition = implode(",",$fieldnames);
283 if (isset($structure["indexes"][$indexname])) {
284 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
286 $new_index_definition = "__NOT_SET__";
288 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
289 $sql2=db_drop_index($indexname);
291 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
297 // Compare the field structure field by field
298 foreach ($structure["fields"] AS $fieldname => $parameters) {
299 if (!isset($database[$name]["fields"][$fieldname])) {
300 $sql2=db_add_table_field($fieldname, $parameters);
302 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
307 // Compare the field definition
308 $field_definition = $database[$name]["fields"][$fieldname];
310 // Remove the relation data that is used for the referential integrity
311 unset($parameters['relation']);
313 // We change the collation after the indexes had been changed.
314 // This is done to avoid index length problems.
315 // So here we always ensure that there is no need to change it.
316 unset($parameters['Collation']);
317 unset($field_definition['Collation']);
319 $current_field_definition = implode(",", $field_definition);
320 $new_field_definition = implode(",", $parameters);
321 if ($current_field_definition != $new_field_definition) {
322 $sql2 = db_modify_table_field($fieldname, $parameters);
324 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
334 * Create the index if the index don't exists in database
335 * or the definition differ from the current status.
336 * Don't create keys if table is new
338 if (!$is_new_table) {
339 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
340 if (isset($database[$name]["indexes"][$indexname])) {
341 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
343 $current_index_definition = "__NOT_SET__";
345 $new_index_definition = implode(",",$fieldnames);
346 if ($current_index_definition != $new_index_definition) {
347 $sql2 = db_create_index($indexname, $fieldnames);
349 // Fetch the "group by" fields for unique indexes
350 if ($fieldnames[0] == "UNIQUE") {
351 $group_by = db_group_by($indexname, $fieldnames);
355 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
363 if (isset($database[$name]["table_status"]["Collation"])) {
364 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
365 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
368 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
379 // Now have a look at the field collations
380 // Compare the field structure field by field
381 foreach ($structure["fields"] AS $fieldname => $parameters) {
382 // Compare the field definition
383 $field_definition = $database[$name]["fields"][$fieldname];
385 // Define the default collation if not given
386 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
387 $parameters['Collation'] = 'utf8mb4_general_ci';
389 $parameters['Collation'] = null;
392 if ($field_definition['Collation'] != $parameters['Collation']) {
393 $sql2 = db_modify_table_field($fieldname, $parameters);
394 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
395 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
404 if (substr($sql3, -2, 2) != "; ") {
409 if ($is_unique && $ignore == '') {
410 foreach ($structure['fields'] AS $fieldname => $parameters) {
411 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
413 $field_list = rtrim($field_list, ',');
417 // Ensure index conversion to unique removes duplicates
420 echo "SET session old_alter_table=1;\n";
422 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
430 echo "SET session old_alter_table=0;\n";
432 echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
433 echo "DROP TABLE `".$name."`;\n";
434 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
440 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
442 // Ensure index conversion to unique removes duplicates
445 $db->q("SET session old_alter_table=1;");
447 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
448 if (!dbm::is_result($r)) {
449 $errors .= print_update_error($db, $sql3);
456 if (!dbm::is_result($r)) {
457 $errors .= print_update_error($db, $sql3);
461 $db->q("SET session old_alter_table=0;");
463 $r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
464 if (!dbm::is_result($r)) {
465 $errors .= print_update_error($db, $sql3);
468 $r = $db->q("DROP TABLE `".$name."`;");
469 if (!dbm::is_result($r)) {
470 $errors .= print_update_error($db, $sql3);
473 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
474 if (!dbm::is_result($r)) {
475 $errors .= print_update_error($db, $sql3);
485 Config::set('system', 'maintenance', 0);
486 Config::set('system', 'maintenance_reason', '');
490 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
492 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
498 function db_field_command($parameters, $create = true) {
499 $fieldstruct = $parameters["type"];
501 if (!is_null($parameters["Collation"])) {
502 $fieldstruct .= " COLLATE ".$parameters["Collation"];
505 if ($parameters["not null"])
506 $fieldstruct .= " NOT NULL";
508 if (isset($parameters["default"])) {
509 if (strpos(strtolower($parameters["type"]),"int")!==false) {
510 $fieldstruct .= " DEFAULT ".$parameters["default"];
512 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
515 if ($parameters["extra"] != "")
516 $fieldstruct .= " ".$parameters["extra"];
518 /*if (($parameters["primary"] != "") && $create)
519 $fieldstruct .= " PRIMARY KEY";*/
521 return($fieldstruct);
524 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
532 $primary_keys = array();
533 foreach ($fields AS $fieldname => $field) {
534 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
535 if (x($field,'primary') && $field['primary']!='') {
536 $primary_keys[] = $fieldname;
540 if (!is_null($indexes)) {
541 foreach ($indexes AS $indexname => $fieldnames) {
542 $sql_index = db_create_index($indexname, $fieldnames, "");
543 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
547 $sql = implode(",\n\t", $sql_rows);
549 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
559 function db_add_table_field($fieldname, $parameters) {
560 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
564 function db_modify_table_field($fieldname, $parameters) {
565 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
569 function db_drop_index($indexname) {
570 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
574 function db_create_index($indexname, $fieldnames, $method="ADD") {
576 $method = strtoupper(trim($method));
577 if ($method!="" && $method!="ADD") {
578 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
582 if ($fieldnames[0] == "UNIQUE") {
583 array_shift($fieldnames);
584 $method .= ' UNIQUE';
588 foreach ($fieldnames AS $fieldname) {
592 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
593 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
595 $names .= "`".dbesc($fieldname)."`";
599 if ($indexname == "PRIMARY") {
600 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
604 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
608 function db_group_by($indexname, $fieldnames) {
610 if ($fieldnames[0] != "UNIQUE") {
614 array_shift($fieldnames);
617 foreach ($fieldnames AS $fieldname) {
621 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
622 $names .= "`".dbesc($matches[1])."`";
624 $names .= "`".dbesc($fieldname)."`";
628 $sql = sprintf(" GROUP BY %s", $names);
632 function db_definition() {
636 $database["addon"] = array(
638 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
639 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
640 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
641 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
642 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
643 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
644 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
647 "PRIMARY" => array("id"),
648 "name" => array("UNIQUE", "name"),
651 $database["attach"] = array(
653 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
654 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
655 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
656 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
657 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
658 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
659 "data" => array("type" => "longblob", "not null" => "1"),
660 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
661 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
662 "allow_cid" => array("type" => "mediumtext"),
663 "allow_gid" => array("type" => "mediumtext"),
664 "deny_cid" => array("type" => "mediumtext"),
665 "deny_gid" => array("type" => "mediumtext"),
668 "PRIMARY" => array("id"),
671 $database["auth_codes"] = array(
673 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
674 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
675 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
676 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
677 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
680 "PRIMARY" => array("id"),
683 $database["cache"] = array(
685 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
686 "v" => array("type" => "mediumtext"),
687 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
688 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
691 "PRIMARY" => array("k"),
692 "expire_mode_updated" => array("expire_mode", "updated"),
695 $database["challenge"] = array(
697 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
698 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
700 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
701 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
702 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
705 "PRIMARY" => array("id"),
708 $database["clients"] = array(
710 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
711 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
712 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
713 "name" => array("type" => "text"),
714 "icon" => array("type" => "text"),
715 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
718 "PRIMARY" => array("client_id"),
721 $database["config"] = array(
723 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
724 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
725 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
726 "v" => array("type" => "mediumtext"),
729 "PRIMARY" => array("id"),
730 "cat_k" => array("UNIQUE", "cat", "k"),
733 $database["contact"] = array(
735 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
736 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
737 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
738 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
739 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
740 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
741 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
742 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "about" => array("type" => "text"),
747 "keywords" => array("type" => "text"),
748 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
749 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
751 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "photo" => array("type" => "text"),
753 "thumb" => array("type" => "text"),
754 "micro" => array("type" => "text"),
755 "site-pubkey" => array("type" => "text"),
756 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
761 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
762 "pubkey" => array("type" => "text"),
763 "prvkey" => array("type" => "text"),
764 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
765 "request" => array("type" => "text"),
766 "notify" => array("type" => "text"),
767 "poll" => array("type" => "text"),
768 "confirm" => array("type" => "text"),
769 "poco" => array("type" => "text"),
770 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
772 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
775 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
776 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
777 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
778 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
779 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
780 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
781 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
782 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
783 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
784 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
785 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
786 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
787 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
790 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
792 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
793 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
794 "reason" => array("type" => "text"),
795 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
796 "info" => array("type" => "mediumtext"),
797 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
798 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
799 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
800 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
801 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
802 "ffi_keyword_blacklist" => array("type" => "text"),
805 "PRIMARY" => array("id"),
806 "uid_name" => array("uid", "name(190)"),
807 "self_uid" => array("self", "uid"),
808 "alias_uid" => array("alias(32)", "uid"),
809 "pending_uid" => array("pending", "uid"),
810 "blocked_uid" => array("blocked", "uid"),
811 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
812 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
813 "addr_uid" => array("addr(32)", "uid"),
814 "nurl_uid" => array("nurl(32)", "uid"),
815 "nick_uid" => array("nick(32)", "uid"),
816 "dfrn-id" => array("dfrn-id"),
817 "issued-id" => array("issued-id"),
820 $database["conv"] = array(
822 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
823 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
824 "recips" => array("type" => "text"),
825 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
826 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
827 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
828 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
829 "subject" => array("type" => "text"),
832 "PRIMARY" => array("id"),
833 "uid" => array("uid"),
836 $database["conversation"] = array(
838 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
839 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
840 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
841 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
842 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
843 "source" => array("type" => "mediumtext"),
844 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
847 "PRIMARY" => array("item-uri"),
848 "conversation-uri" => array("conversation-uri"),
851 $database["event"] = array(
853 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
854 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
855 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
856 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
857 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
858 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
859 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
860 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
861 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
862 "summary" => array("type" => "text"),
863 "desc" => array("type" => "text"),
864 "location" => array("type" => "text"),
865 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
866 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
867 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
868 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
869 "allow_cid" => array("type" => "mediumtext"),
870 "allow_gid" => array("type" => "mediumtext"),
871 "deny_cid" => array("type" => "mediumtext"),
872 "deny_gid" => array("type" => "mediumtext"),
875 "PRIMARY" => array("id"),
876 "uid_start" => array("uid", "start"),
879 $database["fcontact"] = array(
881 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
882 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
883 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
885 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
886 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
889 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
892 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
893 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
894 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
895 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
896 "pubkey" => array("type" => "text"),
897 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
900 "PRIMARY" => array("id"),
901 "addr" => array("addr(32)"),
902 "url" => array("UNIQUE", "url(190)"),
905 $database["ffinder"] = array(
907 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
908 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
909 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
910 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
913 "PRIMARY" => array("id"),
916 $database["fserver"] = array(
918 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
919 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
920 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
921 "key" => array("type" => "text"),
924 "PRIMARY" => array("id"),
925 "server" => array("server(32)"),
928 $database["fsuggest"] = array(
930 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
931 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
932 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
933 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
934 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
935 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
936 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
937 "note" => array("type" => "text"),
938 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
941 "PRIMARY" => array("id"),
944 $database["gcign"] = array(
946 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
947 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
948 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
951 "PRIMARY" => array("id"),
952 "uid" => array("uid"),
953 "gcid" => array("gcid"),
956 $database["gcontact"] = array(
958 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
959 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
963 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
964 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
965 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
966 "updated" => array("type" => "datetime", "default" => NULL_DATE),
967 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
968 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
969 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
970 "about" => array("type" => "text"),
971 "keywords" => array("type" => "text"),
972 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
973 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
974 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
975 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
976 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
977 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
978 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
979 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
980 "notify" => array("type" => "text"),
981 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
982 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
983 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
986 "PRIMARY" => array("id"),
987 "nurl" => array("UNIQUE", "nurl(190)"),
988 "name" => array("name(64)"),
989 "nick" => array("nick(32)"),
990 "addr" => array("addr(64)"),
991 "hide_network_updated" => array("hide", "network(4)", "updated"),
992 "updated" => array("updated"),
995 $database["glink"] = array(
997 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
998 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
999 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1000 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1001 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1002 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1005 "PRIMARY" => array("id"),
1006 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
1007 "gcid" => array("gcid"),
1010 $database["group"] = array(
1012 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1013 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1014 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1015 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1016 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1019 "PRIMARY" => array("id"),
1020 "uid" => array("uid"),
1023 $database["group_member"] = array(
1025 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1026 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1027 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1028 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1031 "PRIMARY" => array("id"),
1032 "contactid" => array("contact-id"),
1033 "gid_contactid" => array("gid", "contact-id"),
1034 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1037 $database["gserver"] = array(
1039 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1040 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1042 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "info" => array("type" => "text"),
1045 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1046 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1049 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1050 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1051 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1052 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1053 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1056 "PRIMARY" => array("id"),
1057 "nurl" => array("UNIQUE", "nurl(190)"),
1060 $database["hook"] = array(
1062 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1063 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1064 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1065 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1066 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1069 "PRIMARY" => array("id"),
1070 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1073 $database["intro"] = array(
1075 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1076 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1077 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1078 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1079 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1080 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1081 "note" => array("type" => "text"),
1082 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1083 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1084 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1085 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1088 "PRIMARY" => array("id"),
1091 $database["item"] = array(
1093 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1094 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1095 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1096 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1097 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1098 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1099 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1100 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1101 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1102 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1103 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1107 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1108 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1109 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1110 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1111 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1112 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1113 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1114 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1115 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1116 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1118 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1119 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1120 "body" => array("type" => "mediumtext"),
1121 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1122 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1124 "object" => array("type" => "text"),
1125 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1126 "target" => array("type" => "text"),
1127 "postopts" => array("type" => "text"),
1128 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1129 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1130 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1131 "tag" => array("type" => "mediumtext"),
1132 "attach" => array("type" => "mediumtext"),
1133 "inform" => array("type" => "mediumtext"),
1134 "file" => array("type" => "mediumtext"),
1135 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1136 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1137 "allow_cid" => array("type" => "mediumtext"),
1138 "allow_gid" => array("type" => "mediumtext"),
1139 "deny_cid" => array("type" => "mediumtext"),
1140 "deny_gid" => array("type" => "mediumtext"),
1141 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1142 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1143 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1144 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1145 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1146 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1147 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1148 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1149 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1150 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1151 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1152 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1153 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1154 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1155 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1156 "rendered-html" => array("type" => "mediumtext"),
1157 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1160 "PRIMARY" => array("id"),
1161 "guid" => array("guid"),
1162 "uri" => array("uri"),
1163 "parent" => array("parent"),
1164 "parent-uri" => array("parent-uri"),
1165 "extid" => array("extid"),
1166 "uid_id" => array("uid","id"),
1167 "uid_contactid_id" => array("uid","contact-id","id"),
1168 "uid_created" => array("uid","created"),
1169 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1170 "uid_network_received" => array("uid","network(4)","received"),
1171 "uid_network_commented" => array("uid","network(4)","commented"),
1172 "uid_thrparent" => array("uid","thr-parent(190)"),
1173 "uid_parenturi" => array("uid","parent-uri(190)"),
1174 "uid_contactid_created" => array("uid","contact-id","created"),
1175 "authorid_created" => array("author-id","created"),
1176 "ownerid" => array("owner-id"),
1177 "uid_uri" => array("uid", "uri(190)"),
1178 "resource-id" => array("resource-id"),
1179 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1180 "uid_type_changed" => array("uid","type(190)","changed"),
1181 "contactid_verb" => array("contact-id","verb(190)"),
1182 "deleted_changed" => array("deleted","changed"),
1183 "uid_wall_changed" => array("uid","wall","changed"),
1184 "uid_eventid" => array("uid","event-id"),
1185 "uid_authorlink" => array("uid","author-link(190)"),
1186 "uid_ownerlink" => array("uid","owner-link(190)"),
1189 $database["item_id"] = array(
1191 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1192 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1193 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1194 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1195 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1198 "PRIMARY" => array("id"),
1199 "uid" => array("uid"),
1200 "sid" => array("sid"),
1201 "service" => array("service(32)"),
1202 "iid" => array("iid"),
1205 $database["locks"] = array(
1207 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1208 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1209 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1210 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1213 "PRIMARY" => array("id"),
1216 $database["mail"] = array(
1218 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1219 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1220 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1221 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1222 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1223 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1224 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1225 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1226 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1227 "body" => array("type" => "mediumtext"),
1228 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1229 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1230 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1231 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1232 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1233 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1234 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1237 "PRIMARY" => array("id"),
1238 "uid_seen" => array("uid", "seen"),
1239 "convid" => array("convid"),
1240 "uri" => array("uri(64)"),
1241 "parent-uri" => array("parent-uri(64)"),
1242 "contactid" => array("contact-id"),
1245 $database["mailacct"] = array(
1247 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1248 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1249 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1250 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1251 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1252 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1253 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1254 "pass" => array("type" => "text"),
1255 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1256 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1257 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1258 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1259 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1262 "PRIMARY" => array("id"),
1265 $database["manage"] = array(
1267 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1268 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1269 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1272 "PRIMARY" => array("id"),
1273 "uid_mid" => array("UNIQUE", "uid","mid"),
1276 $database["notify"] = array(
1278 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1279 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1280 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1281 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1282 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1283 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1284 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1285 "msg" => array("type" => "mediumtext"),
1286 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1287 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1288 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1289 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1290 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1291 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1292 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1293 "name_cache" => array("type" => "tinytext"),
1294 "msg_cache" => array("type" => "mediumtext")
1297 "PRIMARY" => array("id"),
1298 "hash_uid" => array("hash", "uid"),
1299 "seen_uid_date" => array("seen", "uid", "date"),
1300 "uid_date" => array("uid", "date"),
1301 "uid_type_link" => array("uid", "type", "link(190)"),
1304 $database["notify-threads"] = array(
1306 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1307 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1308 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1309 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1310 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1313 "PRIMARY" => array("id"),
1316 $database["oembed"] = array(
1318 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1319 "content" => array("type" => "mediumtext"),
1320 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1323 "PRIMARY" => array("url"),
1324 "created" => array("created"),
1327 $database["parsed_url"] = array(
1329 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1330 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1331 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1332 "content" => array("type" => "mediumtext"),
1333 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1336 "PRIMARY" => array("url", "guessing", "oembed"),
1337 "created" => array("created"),
1340 $database["pconfig"] = array(
1342 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1343 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1344 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1345 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1346 "v" => array("type" => "mediumtext"),
1349 "PRIMARY" => array("id"),
1350 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1353 $database["photo"] = array(
1355 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1356 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1357 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1358 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1359 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1360 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1361 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1362 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1363 "desc" => array("type" => "text"),
1364 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1365 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1366 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1367 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1368 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1369 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1370 "data" => array("type" => "mediumblob", "not null" => "1"),
1371 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1372 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1373 "allow_cid" => array("type" => "mediumtext"),
1374 "allow_gid" => array("type" => "mediumtext"),
1375 "deny_cid" => array("type" => "mediumtext"),
1376 "deny_gid" => array("type" => "mediumtext"),
1379 "PRIMARY" => array("id"),
1380 "contactid" => array("contact-id"),
1381 "uid_contactid" => array("uid", "contact-id"),
1382 "uid_profile" => array("uid", "profile"),
1383 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1384 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1385 "resource-id" => array("resource-id(64)"),
1388 $database["poll"] = array(
1390 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1391 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1392 "q0" => array("type" => "text"),
1393 "q1" => array("type" => "text"),
1394 "q2" => array("type" => "text"),
1395 "q3" => array("type" => "text"),
1396 "q4" => array("type" => "text"),
1397 "q5" => array("type" => "text"),
1398 "q6" => array("type" => "text"),
1399 "q7" => array("type" => "text"),
1400 "q8" => array("type" => "text"),
1401 "q9" => array("type" => "text"),
1404 "PRIMARY" => array("id"),
1405 "uid" => array("uid"),
1408 $database["poll_result"] = array(
1410 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1411 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1412 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1415 "PRIMARY" => array("id"),
1416 "poll_id" => array("poll_id"),
1417 "choice" => array("choice"),
1420 $database["process"] = array(
1422 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1423 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1424 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1427 "PRIMARY" => array("pid"),
1428 "command" => array("command"),
1431 $database["profile"] = array(
1433 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1434 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1435 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1436 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1437 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1438 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1439 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1440 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1441 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1442 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1443 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1444 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1445 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1446 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1447 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1448 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1449 "with" => array("type" => "text"),
1450 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1451 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1452 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1453 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1454 "pub_keywords" => array("type" => "text"),
1455 "prv_keywords" => array("type" => "text"),
1456 "likes" => array("type" => "text"),
1457 "dislikes" => array("type" => "text"),
1458 "about" => array("type" => "text"),
1459 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1460 "music" => array("type" => "text"),
1461 "book" => array("type" => "text"),
1462 "tv" => array("type" => "text"),
1463 "film" => array("type" => "text"),
1464 "interest" => array("type" => "text"),
1465 "romance" => array("type" => "text"),
1466 "work" => array("type" => "text"),
1467 "education" => array("type" => "text"),
1468 "contact" => array("type" => "text"),
1469 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1470 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1471 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1472 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1473 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1474 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1477 "PRIMARY" => array("id"),
1478 "uid_is-default" => array("uid", "is-default"),
1481 $database["profile_check"] = array(
1483 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1484 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1485 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1486 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1487 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1488 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1491 "PRIMARY" => array("id"),
1494 $database["push_subscriber"] = array(
1496 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1497 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1498 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1499 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1500 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1501 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1502 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1503 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1506 "PRIMARY" => array("id"),
1509 $database["queue"] = array(
1511 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1512 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1513 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1514 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1515 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1516 "content" => array("type" => "mediumtext"),
1517 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1520 "PRIMARY" => array("id"),
1521 "cid" => array("cid"),
1522 "created" => array("created"),
1523 "last" => array("last"),
1524 "network" => array("network"),
1525 "batch" => array("batch"),
1528 $database["register"] = array(
1530 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1531 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1532 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1533 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1534 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1535 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1536 "note" => array("type" => "text"),
1539 "PRIMARY" => array("id"),
1542 $database["search"] = array(
1544 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1545 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1546 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1549 "PRIMARY" => array("id"),
1550 "uid" => array("uid"),
1553 $database["session"] = array(
1555 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1556 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1557 "data" => array("type" => "text"),
1558 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1561 "PRIMARY" => array("id"),
1562 "sid" => array("sid(64)"),
1563 "expire" => array("expire"),
1566 $database["sign"] = array(
1568 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1569 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1570 "signed_text" => array("type" => "mediumtext"),
1571 "signature" => array("type" => "text"),
1572 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1575 "PRIMARY" => array("id"),
1576 "iid" => array("UNIQUE", "iid"),
1579 $database["spam"] = array(
1581 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1582 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1583 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1584 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1585 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1586 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1589 "PRIMARY" => array("id"),
1590 "uid" => array("uid"),
1591 "spam" => array("spam"),
1592 "ham" => array("ham"),
1593 "term" => array("term"),
1596 $database["term"] = array(
1598 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1599 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1600 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1601 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1602 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1603 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1604 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1605 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1606 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1607 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1608 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1609 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1612 "PRIMARY" => array("tid"),
1613 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1614 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1615 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1616 "guid" => array("guid(64)"),
1619 $database["thread"] = array(
1621 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1622 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1623 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1624 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1625 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1626 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1627 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1628 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1629 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1630 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1631 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1632 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1633 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1634 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1635 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1636 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1637 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1638 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1639 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1640 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1641 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1642 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1643 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1644 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1645 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1646 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1649 "PRIMARY" => array("iid"),
1650 "uid_network_commented" => array("uid","network","commented"),
1651 "uid_network_created" => array("uid","network","created"),
1652 "uid_contactid_commented" => array("uid","contact-id","commented"),
1653 "uid_contactid_created" => array("uid","contact-id","created"),
1654 "contactid" => array("contact-id"),
1655 "ownerid" => array("owner-id"),
1656 "authorid" => array("author-id"),
1657 "uid_created" => array("uid","created"),
1658 "uid_commented" => array("uid","commented"),
1659 "uid_wall_created" => array("uid","wall","created"),
1660 "private_wall_received" => array("private","wall","received"),
1663 $database["tokens"] = array(
1665 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1666 "secret" => array("type" => "text"),
1667 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1668 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1669 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1670 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1673 "PRIMARY" => array("id"),
1676 $database["user"] = array(
1678 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1679 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1680 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1681 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1682 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1683 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1684 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1685 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1686 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1687 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1688 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1689 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1690 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1691 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1692 "pubkey" => array("type" => "text"),
1693 "prvkey" => array("type" => "text"),
1694 "spubkey" => array("type" => "text"),
1695 "sprvkey" => array("type" => "text"),
1696 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1697 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1698 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1699 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1700 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1701 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1702 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1703 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1704 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1705 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1706 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1707 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1708 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1709 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1710 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1711 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1712 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1713 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1714 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1715 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1716 "allow_cid" => array("type" => "mediumtext"),
1717 "allow_gid" => array("type" => "mediumtext"),
1718 "deny_cid" => array("type" => "mediumtext"),
1719 "deny_gid" => array("type" => "mediumtext"),
1720 "openidserver" => array("type" => "text"),
1723 "PRIMARY" => array("uid"),
1724 "nickname" => array("nickname(32)"),
1727 $database["userd"] = array(
1729 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1730 "username" => array("type" => "varchar(255)", "not null" => "1"),
1733 "PRIMARY" => array("id"),
1734 "username" => array("username(32)"),
1737 $database["workerqueue"] = array(
1739 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1740 "parameter" => array("type" => "text"),
1741 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1742 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1743 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1744 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1745 "done" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1748 "PRIMARY" => array("id"),
1749 "pid" => array("pid"),
1750 "parameter" => array("parameter(64)"),
1751 "priority_created" => array("priority", "created"),
1752 "executed" => array("executed"),
1761 * run from command line
1763 function dbstructure_run(&$argv, &$argc) {
1767 $a = new App(dirname(__DIR__));
1771 @include ".htconfig.php";
1772 require_once "include/dba.php";
1773 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1774 unset($db_host, $db_user, $db_pass, $db_data);
1780 update_structure(true, false);
1783 update_structure(true, true);
1785 $build = get_config('system','build');
1787 set_config('system', 'build', DB_UPDATE_VERSION);
1788 $build = DB_UPDATE_VERSION;
1791 $stored = intval($build);
1792 $current = intval(DB_UPDATE_VERSION);
1794 // run any left update_nnnn functions in update.php
1795 for ($x = $stored; $x < $current; $x ++) {
1796 $r = run_update_function($x);
1802 set_config('system','build',DB_UPDATE_VERSION);
1805 print_structure(db_definition());
1808 convert_to_innodb();
1815 echo $argv[0]." <command>\n";
1818 echo "dryrun show database update schema queries without running them\n";
1819 echo "update update database schema\n";
1820 echo "dumpsql dump database schema\n";
1821 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1826 if (array_search(__FILE__,get_included_files())===0) {
1827 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);