4 use Friendica\Core\Config;
6 require_once "boot.php";
7 require_once "include/text.php";
9 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
11 const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before
12 const DB_UPDATE_SUCCESSFUL = 1; // Database check was successful
13 const DB_UPDATE_FAILED = 2; // Database check failed
16 * Converts all tables from MyISAM to InnoDB
18 function convert_to_innodb() {
21 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
22 dbesc($db->database_name()));
24 if (!dbm::is_result($r)) {
25 echo t('There are no tables on MyISAM.')."\n";
29 foreach ($r AS $table) {
30 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
33 $result = $db->q($sql);
34 if (!dbm::is_result($result)) {
35 print_update_error($db, $sql);
41 * send the email and do what is needed to do on update fails
43 * @param update_id (int) number of failed update
44 * @param error_message (str) error message
46 function update_fail($update_id, $error_message) {
47 //send the administrators an e-mail
48 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
49 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
54 if (!dbm::is_result($adminlist)) {
55 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
61 // every admin could had different language
62 foreach ($adminlist as $admin) {
63 $lang = (($admin['language'])?$admin['language']:'en');
66 $preamble = deindent(t("
67 The friendica developers released update %s recently,
68 but when I tried to install it, something went terribly wrong.
69 This needs to be fixed soon and I can't do it alone. Please contact a
70 friendica developer if you can not help me on your own. My database might be invalid."));
71 $body = t("The error message is\n[pre]%s[/pre]");
72 $preamble = sprintf($preamble, $update_id);
73 $body = sprintf($body, $error_message);
76 'type' => "SYSTEM_EMAIL",
77 'to_email' => $admin['email'],
78 'preamble' => $preamble,
88 @TODO deprecated code?
89 $email_tpl = get_intltext_template("update_fail_eml.tpl");
90 $email_msg = replace_macros($email_tpl, array(
91 '$sitename' => $a->config['sitename'],
92 '$siteurl' => App::get_baseurl(),
93 '$update' => DB_UPDATE_VERSION,
94 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
96 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
97 require_once('include/email.php');
98 $subject = email_header_encode($subject,'UTF-8');
99 mail($a->config['admin_email'], $subject, $email_msg,
100 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
101 .'Content-type: text/plain; charset=UTF-8'."\n"
102 .'Content-transfer-encoding: 8bit');
105 logger("CRITICAL: Database structure update failed: ".$retval);
109 function table_structure($table) {
110 $structures = q("DESCRIBE `%s`", $table);
112 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
114 $indexes = q("SHOW INDEX FROM `%s`", $table);
116 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
118 if (dbm::is_result($table_status)) {
119 $table_status = $table_status[0];
121 $table_status = array();
124 $fielddata = array();
125 $indexdata = array();
127 if (dbm::is_result($indexes))
128 foreach ($indexes AS $index) {
129 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
130 $indexdata[$index["Key_name"]] = array('UNIQUE');
133 $column = $index["Column_name"];
134 // On utf8mb4 a varchar index can only have a length of 191
135 // The "show index" command sometimes returns this value although this value wasn't added manually.
136 // Because we don't want to add this number to every index, we ignore bigger numbers
137 if (($index["Sub_part"] != "") && (($index["Sub_part"] < 191) || ($index["Key_name"] == "PRIMARY"))) {
138 $column .= "(".$index["Sub_part"].")";
141 $indexdata[$index["Key_name"]][] = $column;
143 if (dbm::is_result($structures)) {
144 foreach ($structures AS $field) {
145 $fielddata[$field["Field"]]["type"] = $field["Type"];
146 if ($field["Null"] == "NO") {
147 $fielddata[$field["Field"]]["not null"] = true;
150 if (isset($field["Default"])) {
151 $fielddata[$field["Field"]]["default"] = $field["Default"];
154 if ($field["Extra"] != "") {
155 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
158 if ($field["Key"] == "PRI") {
159 $fielddata[$field["Field"]]["primary"] = true;
163 if (dbm::is_result($full_columns)) {
164 foreach ($full_columns AS $column) {
165 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
169 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
172 function print_structure($database) {
173 echo "-- ------------------------------------------\n";
174 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
175 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
176 echo "-- ------------------------------------------\n\n\n";
177 foreach ($database AS $name => $structure) {
179 echo "-- TABLE $name\n";
181 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
188 * @brief Print out database error messages
190 * @param object $db Database object
191 * @param string $message Message to be added to the error message
193 * @return string Error message
195 function print_update_error($db, $message) {
196 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
197 $db->errorno, $db->error);
199 return t('Errors encountered performing database changes: ').$message.EOL;
202 function update_structure($verbose, $action, $tables=null, $definition=null) {
206 Config::set('system', 'maintenance', 1);
207 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
212 logger('updating structure', LOGGER_DEBUG);
214 // Get the current structure
217 if (is_null($tables)) {
218 $tables = q("SHOW TABLES");
221 if (dbm::is_result($tables)) {
222 foreach ($tables AS $table) {
223 $table = current($table);
225 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
226 $database[$table] = table_structure($table);
230 // Get the definition
231 if (is_null($definition)) {
232 $definition = db_definition();
235 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
236 if ((version_compare($db->server_info(), '5.7.4') >= 0) &&
237 !(strpos($db->server_info(), 'MariaDB') !== false)) {
244 foreach ($definition AS $name => $structure) {
245 $is_new_table = False;
248 if (!isset($database[$name])) {
249 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
250 if (!dbm::is_result($r)) {
251 $errors .= print_update_error($db, $name);
253 $is_new_table = True;
258 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
259 if (isset($database[$name]["indexes"][$indexname])) {
260 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
262 $current_index_definition = "__NOT_SET__";
264 $new_index_definition = implode(",",$fieldnames);
265 if ($current_index_definition != $new_index_definition) {
266 if ($fieldnames[0] == "UNIQUE") {
269 $temp_name = "temp-".$name;
276 * Drop the index if it isn't present in the definition
277 * or the definition differ from current status
278 * and index name doesn't start with "local_"
280 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
281 $current_index_definition = implode(",",$fieldnames);
282 if (isset($structure["indexes"][$indexname])) {
283 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
285 $new_index_definition = "__NOT_SET__";
287 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
288 $sql2=db_drop_index($indexname);
290 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
296 // Compare the field structure field by field
297 foreach ($structure["fields"] AS $fieldname => $parameters) {
298 if (!isset($database[$name]["fields"][$fieldname])) {
299 $sql2=db_add_table_field($fieldname, $parameters);
301 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
306 // Compare the field definition
307 $field_definition = $database[$name]["fields"][$fieldname];
309 // Remove the relation data that is used for the referential integrity
310 unset($parameters['relation']);
312 // We change the collation after the indexes had been changed.
313 // This is done to avoid index length problems.
314 // So here we always ensure that there is no need to change it.
315 unset($parameters['Collation']);
316 unset($field_definition['Collation']);
318 $current_field_definition = implode(",", $field_definition);
319 $new_field_definition = implode(",", $parameters);
320 if ($current_field_definition != $new_field_definition) {
321 $sql2 = db_modify_table_field($fieldname, $parameters);
323 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
333 * Create the index if the index don't exists in database
334 * or the definition differ from the current status.
335 * Don't create keys if table is new
337 if (!$is_new_table) {
338 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
339 if (isset($database[$name]["indexes"][$indexname])) {
340 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
342 $current_index_definition = "__NOT_SET__";
344 $new_index_definition = implode(",",$fieldnames);
345 if ($current_index_definition != $new_index_definition) {
346 $sql2 = db_create_index($indexname, $fieldnames);
348 // Fetch the "group by" fields for unique indexes
349 if ($fieldnames[0] == "UNIQUE") {
350 $group_by = db_group_by($indexname, $fieldnames);
354 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
362 if (isset($database[$name]["table_status"]["Collation"])) {
363 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
364 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
367 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
378 // Now have a look at the field collations
379 // Compare the field structure field by field
380 foreach ($structure["fields"] AS $fieldname => $parameters) {
381 // Compare the field definition
382 $field_definition = $database[$name]["fields"][$fieldname];
384 // Define the default collation if not given
385 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
386 $parameters['Collation'] = 'utf8mb4_general_ci';
388 $parameters['Collation'] = null;
391 if ($field_definition['Collation'] != $parameters['Collation']) {
392 $sql2 = db_modify_table_field($fieldname, $parameters);
393 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
394 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
403 if (substr($sql3, -2, 2) != "; ") {
408 if ($is_unique && $ignore == '') {
409 foreach ($structure['fields'] AS $fieldname => $parameters) {
410 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
412 $field_list = rtrim($field_list, ',');
416 // Ensure index conversion to unique removes duplicates
419 echo "SET session old_alter_table=1;\n";
421 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
429 echo "SET session old_alter_table=0;\n";
431 echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
432 echo "DROP TABLE `".$name."`;\n";
433 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
439 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
441 // Ensure index conversion to unique removes duplicates
444 $db->q("SET session old_alter_table=1;");
446 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
447 if (!dbm::is_result($r)) {
448 $errors .= print_update_error($db, $sql3);
455 if (!dbm::is_result($r)) {
456 $errors .= print_update_error($db, $sql3);
460 $db->q("SET session old_alter_table=0;");
462 $r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
463 if (!dbm::is_result($r)) {
464 $errors .= print_update_error($db, $sql3);
467 $r = $db->q("DROP TABLE `".$name."`;");
468 if (!dbm::is_result($r)) {
469 $errors .= print_update_error($db, $sql3);
472 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
473 if (!dbm::is_result($r)) {
474 $errors .= print_update_error($db, $sql3);
484 Config::set('system', 'maintenance', 0);
485 Config::set('system', 'maintenance_reason', '');
489 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
491 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
497 function db_field_command($parameters, $create = true) {
498 $fieldstruct = $parameters["type"];
500 if (!is_null($parameters["Collation"])) {
501 $fieldstruct .= " COLLATE ".$parameters["Collation"];
504 if ($parameters["not null"])
505 $fieldstruct .= " NOT NULL";
507 if (isset($parameters["default"])) {
508 if (strpos(strtolower($parameters["type"]),"int")!==false) {
509 $fieldstruct .= " DEFAULT ".$parameters["default"];
511 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
514 if ($parameters["extra"] != "")
515 $fieldstruct .= " ".$parameters["extra"];
517 /*if (($parameters["primary"] != "") && $create)
518 $fieldstruct .= " PRIMARY KEY";*/
520 return($fieldstruct);
523 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
531 $primary_keys = array();
532 foreach ($fields AS $fieldname => $field) {
533 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
534 if (x($field,'primary') && $field['primary']!='') {
535 $primary_keys[] = $fieldname;
539 if (!is_null($indexes)) {
540 foreach ($indexes AS $indexname => $fieldnames) {
541 $sql_index = db_create_index($indexname, $fieldnames, "");
542 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
546 $sql = implode(",\n\t", $sql_rows);
548 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
558 function db_add_table_field($fieldname, $parameters) {
559 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
563 function db_modify_table_field($fieldname, $parameters) {
564 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
568 function db_drop_index($indexname) {
569 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
573 function db_create_index($indexname, $fieldnames, $method="ADD") {
575 $method = strtoupper(trim($method));
576 if ($method!="" && $method!="ADD") {
577 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
581 if ($fieldnames[0] == "UNIQUE") {
582 array_shift($fieldnames);
583 $method .= ' UNIQUE';
587 foreach ($fieldnames AS $fieldname) {
591 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
592 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
594 $names .= "`".dbesc($fieldname)."`";
598 if ($indexname == "PRIMARY") {
599 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
603 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
607 function db_group_by($indexname, $fieldnames) {
609 if ($fieldnames[0] != "UNIQUE") {
613 array_shift($fieldnames);
616 foreach ($fieldnames AS $fieldname) {
620 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
621 $names .= "`".dbesc($matches[1])."`";
623 $names .= "`".dbesc($fieldname)."`";
627 $sql = sprintf(" GROUP BY %s", $names);
631 function db_definition() {
635 $database["addon"] = array(
637 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
638 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
639 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
640 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
641 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
642 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
643 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
646 "PRIMARY" => array("id"),
647 "name" => array("UNIQUE", "name"),
650 $database["attach"] = array(
652 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
653 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
654 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
655 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
656 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
657 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
658 "data" => array("type" => "longblob", "not null" => "1"),
659 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
660 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
661 "allow_cid" => array("type" => "mediumtext"),
662 "allow_gid" => array("type" => "mediumtext"),
663 "deny_cid" => array("type" => "mediumtext"),
664 "deny_gid" => array("type" => "mediumtext"),
667 "PRIMARY" => array("id"),
670 $database["auth_codes"] = array(
672 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
673 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
674 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
675 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
676 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
679 "PRIMARY" => array("id"),
682 $database["cache"] = array(
684 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
685 "v" => array("type" => "mediumtext"),
686 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
687 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
690 "PRIMARY" => array("k"),
691 "expire_mode_updated" => array("expire_mode", "updated"),
694 $database["challenge"] = array(
696 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
697 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
698 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
700 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
701 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
704 "PRIMARY" => array("id"),
707 $database["clients"] = array(
709 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
710 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
711 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
712 "name" => array("type" => "text"),
713 "icon" => array("type" => "text"),
714 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
717 "PRIMARY" => array("client_id"),
720 $database["config"] = array(
722 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
723 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
724 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
725 "v" => array("type" => "mediumtext"),
728 "PRIMARY" => array("id"),
729 "cat_k" => array("UNIQUE", "cat", "k"),
732 $database["contact"] = array(
734 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
735 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
736 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
737 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
738 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
739 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
740 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
741 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "about" => array("type" => "text"),
746 "keywords" => array("type" => "text"),
747 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
748 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
751 "photo" => array("type" => "text"),
752 "thumb" => array("type" => "text"),
753 "micro" => array("type" => "text"),
754 "site-pubkey" => array("type" => "text"),
755 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
761 "pubkey" => array("type" => "text"),
762 "prvkey" => array("type" => "text"),
763 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
764 "request" => array("type" => "text"),
765 "notify" => array("type" => "text"),
766 "poll" => array("type" => "text"),
767 "confirm" => array("type" => "text"),
768 "poco" => array("type" => "text"),
769 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
770 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
772 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
774 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
775 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
776 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
777 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
778 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
779 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
780 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
781 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
782 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
783 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
784 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
785 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
786 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
787 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
789 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
790 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
792 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
793 "reason" => array("type" => "text"),
794 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
795 "info" => array("type" => "mediumtext"),
796 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
797 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
798 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
799 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
800 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
801 "ffi_keyword_blacklist" => array("type" => "text"),
804 "PRIMARY" => array("id"),
805 "uid_name" => array("uid", "name(190)"),
806 "self_uid" => array("self", "uid"),
807 "alias_uid" => array("alias(32)", "uid"),
808 "pending_uid" => array("pending", "uid"),
809 "blocked_uid" => array("blocked", "uid"),
810 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
811 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
812 "addr_uid" => array("addr(32)", "uid"),
813 "nurl_uid" => array("nurl(32)", "uid"),
814 "nick_uid" => array("nick(32)", "uid"),
815 "dfrn-id" => array("dfrn-id"),
816 "issued-id" => array("issued-id"),
819 $database["conv"] = array(
821 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
822 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
823 "recips" => array("type" => "text"),
824 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
825 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
826 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
827 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
828 "subject" => array("type" => "text"),
831 "PRIMARY" => array("id"),
832 "uid" => array("uid"),
835 $database["conversation"] = array(
837 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
838 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
839 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
840 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
841 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
842 "source" => array("type" => "mediumtext"),
843 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
846 "PRIMARY" => array("item-uri"),
847 "conversation-uri" => array("conversation-uri"),
850 $database["event"] = array(
852 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
853 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
854 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
855 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
856 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
857 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
858 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
859 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
860 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
861 "summary" => array("type" => "text"),
862 "desc" => array("type" => "text"),
863 "location" => array("type" => "text"),
864 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
865 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
866 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
867 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
868 "allow_cid" => array("type" => "mediumtext"),
869 "allow_gid" => array("type" => "mediumtext"),
870 "deny_cid" => array("type" => "mediumtext"),
871 "deny_gid" => array("type" => "mediumtext"),
874 "PRIMARY" => array("id"),
875 "uid_start" => array("uid", "start"),
878 $database["fcontact"] = array(
880 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
881 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
882 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
883 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
885 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
886 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
889 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
892 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
893 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
894 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
895 "pubkey" => array("type" => "text"),
896 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
899 "PRIMARY" => array("id"),
900 "addr" => array("addr(32)"),
901 "url" => array("UNIQUE", "url(190)"),
904 $database["ffinder"] = array(
906 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
907 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
908 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
909 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
912 "PRIMARY" => array("id"),
915 $database["fserver"] = array(
917 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
918 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
919 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
920 "key" => array("type" => "text"),
923 "PRIMARY" => array("id"),
924 "server" => array("server(32)"),
927 $database["fsuggest"] = array(
929 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
930 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
931 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
932 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
933 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
934 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
935 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
936 "note" => array("type" => "text"),
937 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
940 "PRIMARY" => array("id"),
943 $database["gcign"] = array(
945 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
946 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
947 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
950 "PRIMARY" => array("id"),
951 "uid" => array("uid"),
952 "gcid" => array("gcid"),
955 $database["gcontact"] = array(
957 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
958 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
963 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
964 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
965 "updated" => array("type" => "datetime", "default" => NULL_DATE),
966 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
967 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
968 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
969 "about" => array("type" => "text"),
970 "keywords" => array("type" => "text"),
971 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
972 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
973 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
974 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
975 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
976 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
977 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
978 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
979 "notify" => array("type" => "text"),
980 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
981 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
982 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
985 "PRIMARY" => array("id"),
986 "nurl" => array("UNIQUE", "nurl(190)"),
987 "name" => array("name(64)"),
988 "nick" => array("nick(32)"),
989 "addr" => array("addr(64)"),
990 "hide_network_updated" => array("hide", "network(4)", "updated"),
991 "updated" => array("updated"),
994 $database["glink"] = array(
996 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
997 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
998 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
999 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1000 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1001 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1004 "PRIMARY" => array("id"),
1005 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
1006 "gcid" => array("gcid"),
1009 $database["group"] = array(
1011 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1012 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1013 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1014 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1015 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1018 "PRIMARY" => array("id"),
1019 "uid" => array("uid"),
1022 $database["group_member"] = array(
1024 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1025 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1026 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1027 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1030 "PRIMARY" => array("id"),
1031 "contactid" => array("contact-id"),
1032 "gid_contactid" => array("gid", "contact-id"),
1033 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1036 $database["gserver"] = array(
1038 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1039 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1040 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1042 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043 "info" => array("type" => "text"),
1044 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1045 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1048 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1050 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1051 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1052 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1055 "PRIMARY" => array("id"),
1056 "nurl" => array("UNIQUE", "nurl(190)"),
1059 $database["hook"] = array(
1061 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1062 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1063 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1064 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1065 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1068 "PRIMARY" => array("id"),
1069 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1072 $database["intro"] = array(
1074 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1075 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1076 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1077 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1078 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1079 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1080 "note" => array("type" => "text"),
1081 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1082 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1083 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1084 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1087 "PRIMARY" => array("id"),
1090 $database["item"] = array(
1092 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1093 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1095 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1096 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1097 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1098 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1099 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1100 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1101 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1102 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1106 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1107 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1108 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1109 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1110 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1111 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1112 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1113 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1114 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1115 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1118 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1119 "body" => array("type" => "mediumtext"),
1120 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1121 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1122 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123 "object" => array("type" => "text"),
1124 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1125 "target" => array("type" => "text"),
1126 "postopts" => array("type" => "text"),
1127 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1128 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1129 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1130 "tag" => array("type" => "mediumtext"),
1131 "attach" => array("type" => "mediumtext"),
1132 "inform" => array("type" => "mediumtext"),
1133 "file" => array("type" => "mediumtext"),
1134 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1135 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1136 "allow_cid" => array("type" => "mediumtext"),
1137 "allow_gid" => array("type" => "mediumtext"),
1138 "deny_cid" => array("type" => "mediumtext"),
1139 "deny_gid" => array("type" => "mediumtext"),
1140 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1141 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1142 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1143 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1144 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1145 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1146 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1147 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1148 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1149 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1150 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1151 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1152 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1153 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1154 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1155 "rendered-html" => array("type" => "mediumtext"),
1156 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1159 "PRIMARY" => array("id"),
1160 "guid" => array("guid"),
1161 "uri" => array("uri"),
1162 "parent" => array("parent"),
1163 "parent-uri" => array("parent-uri"),
1164 "extid" => array("extid"),
1165 "uid_id" => array("uid","id"),
1166 "uid_contactid_id" => array("uid","contact-id","id"),
1167 "uid_created" => array("uid","created"),
1168 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1169 "uid_network_received" => array("uid","network(4)","received"),
1170 "uid_network_commented" => array("uid","network(4)","commented"),
1171 "uid_thrparent" => array("uid","thr-parent(190)"),
1172 "uid_parenturi" => array("uid","parent-uri(190)"),
1173 "uid_contactid_created" => array("uid","contact-id","created"),
1174 "authorid_created" => array("author-id","created"),
1175 "ownerid" => array("owner-id"),
1176 "uid_uri" => array("uid", "uri(190)"),
1177 "resource-id" => array("resource-id"),
1178 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1179 "uid_type_changed" => array("uid","type(190)","changed"),
1180 "contactid_verb" => array("contact-id","verb(190)"),
1181 "deleted_changed" => array("deleted","changed"),
1182 "uid_wall_changed" => array("uid","wall","changed"),
1183 "uid_eventid" => array("uid","event-id"),
1184 "uid_authorlink" => array("uid","author-link(190)"),
1185 "uid_ownerlink" => array("uid","owner-link(190)"),
1188 $database["item_id"] = array(
1190 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1191 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1192 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1193 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1194 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1197 "PRIMARY" => array("id"),
1198 "uid" => array("uid"),
1199 "sid" => array("sid"),
1200 "service" => array("service(32)"),
1201 "iid" => array("iid"),
1204 $database["locks"] = array(
1206 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1207 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1208 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1209 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1212 "PRIMARY" => array("id"),
1215 $database["mail"] = array(
1217 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1218 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1219 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1220 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1221 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1222 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1223 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1224 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1225 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1226 "body" => array("type" => "mediumtext"),
1227 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1228 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1229 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1230 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1231 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1232 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1233 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1236 "PRIMARY" => array("id"),
1237 "uid_seen" => array("uid", "seen"),
1238 "convid" => array("convid"),
1239 "uri" => array("uri(64)"),
1240 "parent-uri" => array("parent-uri(64)"),
1241 "contactid" => array("contact-id"),
1244 $database["mailacct"] = array(
1246 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1247 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1248 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1249 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1250 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1251 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1252 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1253 "pass" => array("type" => "text"),
1254 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1255 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1256 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1257 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1258 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1261 "PRIMARY" => array("id"),
1264 $database["manage"] = array(
1266 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1267 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1268 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1271 "PRIMARY" => array("id"),
1272 "uid_mid" => array("UNIQUE", "uid","mid"),
1275 $database["notify"] = array(
1277 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1278 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1279 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1280 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1281 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1282 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1283 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1284 "msg" => array("type" => "mediumtext"),
1285 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1286 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1287 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1288 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1289 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1290 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1291 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1292 "name_cache" => array("type" => "tinytext"),
1293 "msg_cache" => array("type" => "mediumtext")
1296 "PRIMARY" => array("id"),
1297 "hash_uid" => array("hash", "uid"),
1298 "seen_uid_date" => array("seen", "uid", "date"),
1299 "uid_date" => array("uid", "date"),
1300 "uid_type_link" => array("uid", "type", "link(190)"),
1303 $database["notify-threads"] = array(
1305 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1306 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1307 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1308 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1309 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1312 "PRIMARY" => array("id"),
1315 $database["oembed"] = array(
1317 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1318 "content" => array("type" => "mediumtext"),
1319 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1322 "PRIMARY" => array("url"),
1323 "created" => array("created"),
1326 $database["parsed_url"] = array(
1328 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1329 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1330 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1331 "content" => array("type" => "mediumtext"),
1332 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1335 "PRIMARY" => array("url", "guessing", "oembed"),
1336 "created" => array("created"),
1339 $database["pconfig"] = array(
1341 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1342 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1343 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1344 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1345 "v" => array("type" => "mediumtext"),
1348 "PRIMARY" => array("id"),
1349 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1352 $database["photo"] = array(
1354 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1355 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1356 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1357 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1358 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1359 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1360 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1361 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1362 "desc" => array("type" => "text"),
1363 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1364 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1365 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1366 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1367 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1368 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1369 "data" => array("type" => "mediumblob", "not null" => "1"),
1370 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1371 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1372 "allow_cid" => array("type" => "mediumtext"),
1373 "allow_gid" => array("type" => "mediumtext"),
1374 "deny_cid" => array("type" => "mediumtext"),
1375 "deny_gid" => array("type" => "mediumtext"),
1378 "PRIMARY" => array("id"),
1379 "contactid" => array("contact-id"),
1380 "uid_contactid" => array("uid", "contact-id"),
1381 "uid_profile" => array("uid", "profile"),
1382 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1383 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1384 "resource-id" => array("resource-id(64)"),
1387 $database["poll"] = array(
1389 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1390 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1391 "q0" => array("type" => "text"),
1392 "q1" => array("type" => "text"),
1393 "q2" => array("type" => "text"),
1394 "q3" => array("type" => "text"),
1395 "q4" => array("type" => "text"),
1396 "q5" => array("type" => "text"),
1397 "q6" => array("type" => "text"),
1398 "q7" => array("type" => "text"),
1399 "q8" => array("type" => "text"),
1400 "q9" => array("type" => "text"),
1403 "PRIMARY" => array("id"),
1404 "uid" => array("uid"),
1407 $database["poll_result"] = array(
1409 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1410 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1411 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1414 "PRIMARY" => array("id"),
1415 "poll_id" => array("poll_id"),
1416 "choice" => array("choice"),
1419 $database["process"] = array(
1421 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1422 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1423 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1426 "PRIMARY" => array("pid"),
1427 "command" => array("command"),
1430 $database["profile"] = array(
1432 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1433 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1434 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1435 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1436 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1437 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1438 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1439 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1440 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1441 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1442 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1443 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1444 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1445 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1446 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1447 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1448 "with" => array("type" => "text"),
1449 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1450 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1451 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1452 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1453 "pub_keywords" => array("type" => "text"),
1454 "prv_keywords" => array("type" => "text"),
1455 "likes" => array("type" => "text"),
1456 "dislikes" => array("type" => "text"),
1457 "about" => array("type" => "text"),
1458 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1459 "music" => array("type" => "text"),
1460 "book" => array("type" => "text"),
1461 "tv" => array("type" => "text"),
1462 "film" => array("type" => "text"),
1463 "interest" => array("type" => "text"),
1464 "romance" => array("type" => "text"),
1465 "work" => array("type" => "text"),
1466 "education" => array("type" => "text"),
1467 "contact" => array("type" => "text"),
1468 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1469 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1470 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1471 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1472 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1473 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1476 "PRIMARY" => array("id"),
1477 "uid_is-default" => array("uid", "is-default"),
1480 $database["profile_check"] = array(
1482 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1483 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1484 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1485 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1486 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1487 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1490 "PRIMARY" => array("id"),
1493 $database["push_subscriber"] = array(
1495 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1496 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1497 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1498 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1499 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1500 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1501 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1502 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1505 "PRIMARY" => array("id"),
1508 $database["queue"] = array(
1510 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1511 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1512 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1513 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1514 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1515 "content" => array("type" => "mediumtext"),
1516 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1519 "PRIMARY" => array("id"),
1520 "cid" => array("cid"),
1521 "created" => array("created"),
1522 "last" => array("last"),
1523 "network" => array("network"),
1524 "batch" => array("batch"),
1527 $database["register"] = array(
1529 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1530 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1531 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1532 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1533 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1534 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1535 "note" => array("type" => "text"),
1538 "PRIMARY" => array("id"),
1541 $database["search"] = array(
1543 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1544 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1545 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1548 "PRIMARY" => array("id"),
1549 "uid" => array("uid"),
1552 $database["session"] = array(
1554 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1555 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1556 "data" => array("type" => "text"),
1557 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1560 "PRIMARY" => array("id"),
1561 "sid" => array("sid(64)"),
1562 "expire" => array("expire"),
1565 $database["sign"] = array(
1567 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1568 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1569 "signed_text" => array("type" => "mediumtext"),
1570 "signature" => array("type" => "text"),
1571 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1574 "PRIMARY" => array("id"),
1575 "iid" => array("UNIQUE", "iid"),
1578 $database["spam"] = array(
1580 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1581 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1582 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1583 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1584 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1585 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1588 "PRIMARY" => array("id"),
1589 "uid" => array("uid"),
1590 "spam" => array("spam"),
1591 "ham" => array("ham"),
1592 "term" => array("term"),
1595 $database["term"] = array(
1597 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1598 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1599 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1600 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1601 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1602 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1603 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1604 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1605 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1606 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1607 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1608 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1611 "PRIMARY" => array("tid"),
1612 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1613 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1614 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1615 "guid" => array("guid(64)"),
1618 $database["thread"] = array(
1620 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1621 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1622 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1623 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1624 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1625 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1626 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1627 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1628 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1629 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1630 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1631 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1632 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1633 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1634 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1635 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1636 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1637 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1638 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1639 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1640 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1641 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1642 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1643 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1644 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1645 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1648 "PRIMARY" => array("iid"),
1649 "uid_network_commented" => array("uid","network","commented"),
1650 "uid_network_created" => array("uid","network","created"),
1651 "uid_contactid_commented" => array("uid","contact-id","commented"),
1652 "uid_contactid_created" => array("uid","contact-id","created"),
1653 "contactid" => array("contact-id"),
1654 "ownerid" => array("owner-id"),
1655 "authorid" => array("author-id"),
1656 "uid_created" => array("uid","created"),
1657 "uid_commented" => array("uid","commented"),
1658 "uid_wall_created" => array("uid","wall","created"),
1659 "private_wall_received" => array("private","wall","received"),
1662 $database["tokens"] = array(
1664 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1665 "secret" => array("type" => "text"),
1666 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1667 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1668 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1669 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1672 "PRIMARY" => array("id"),
1675 $database["user"] = array(
1677 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1678 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1679 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1680 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1681 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1682 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1683 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1684 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1685 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1686 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1687 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1688 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1689 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1690 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1691 "pubkey" => array("type" => "text"),
1692 "prvkey" => array("type" => "text"),
1693 "spubkey" => array("type" => "text"),
1694 "sprvkey" => array("type" => "text"),
1695 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1696 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1697 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1698 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1699 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1700 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1701 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1702 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1703 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1704 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1705 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1706 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1707 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1708 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1709 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1710 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1711 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1712 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1713 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1714 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1715 "allow_cid" => array("type" => "mediumtext"),
1716 "allow_gid" => array("type" => "mediumtext"),
1717 "deny_cid" => array("type" => "mediumtext"),
1718 "deny_gid" => array("type" => "mediumtext"),
1719 "openidserver" => array("type" => "text"),
1722 "PRIMARY" => array("uid"),
1723 "nickname" => array("nickname(32)"),
1726 $database["userd"] = array(
1728 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1729 "username" => array("type" => "varchar(255)", "not null" => "1"),
1732 "PRIMARY" => array("id"),
1733 "username" => array("username(32)"),
1736 $database["workerqueue"] = array(
1738 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1739 "parameter" => array("type" => "text"),
1740 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1741 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1742 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1743 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1744 "done" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1747 "PRIMARY" => array("id"),
1748 "pid" => array("pid"),
1749 "parameter" => array("parameter(64)"),
1750 "priority_created" => array("priority", "created"),
1751 "executed" => array("executed"),
1760 * run from command line
1762 function dbstructure_run(&$argv, &$argc) {
1766 $a = new App(dirname(__DIR__));
1770 @include ".htconfig.php";
1771 require_once "include/dba.php";
1772 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1773 unset($db_host, $db_user, $db_pass, $db_data);
1779 update_structure(true, false);
1782 update_structure(true, true);
1784 $build = get_config('system','build');
1786 set_config('system', 'build', DB_UPDATE_VERSION);
1787 $build = DB_UPDATE_VERSION;
1790 $stored = intval($build);
1791 $current = intval(DB_UPDATE_VERSION);
1793 // run any left update_nnnn functions in update.php
1794 for ($x = $stored; $x < $current; $x ++) {
1795 $r = run_update_function($x);
1801 set_config('system','build',DB_UPDATE_VERSION);
1804 print_structure(db_definition());
1807 convert_to_innodb();
1814 echo $argv[0]." <command>\n";
1817 echo "dryrun show database update schema queries without running them\n";
1818 echo "update update database schema\n";
1819 echo "dumpsql dump database schema\n";
1820 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1825 if (array_search(__FILE__,get_included_files())===0) {
1826 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);