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() {
20 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
21 dbesc(dba::database_name()));
23 if (!dbm::is_result($r)) {
24 echo t('There are no tables on MyISAM.')."\n";
28 foreach ($r AS $table) {
29 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
32 $result = dba::e($sql);
33 if (!dbm::is_result($result)) {
34 print_update_error($sql);
40 * send the email and do what is needed to do on update fails
42 * @param update_id (int) number of failed update
43 * @param error_message (str) error message
45 function update_fail($update_id, $error_message) {
46 //send the administrators an e-mail
47 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
48 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
53 if (!dbm::is_result($adminlist)) {
54 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
60 // every admin could had different language
61 foreach ($adminlist as $admin) {
62 $lang = (($admin['language'])?$admin['language']:'en');
65 $preamble = deindent(t("
66 The friendica developers released update %s recently,
67 but when I tried to install it, something went terribly wrong.
68 This needs to be fixed soon and I can't do it alone. Please contact a
69 friendica developer if you can not help me on your own. My database might be invalid."));
70 $body = t("The error message is\n[pre]%s[/pre]");
71 $preamble = sprintf($preamble, $update_id);
72 $body = sprintf($body, $error_message);
75 'type' => SYSTEM_EMAIL,
76 'to_email' => $admin['email'],
77 'preamble' => $preamble,
87 @TODO deprecated code?
88 $email_tpl = get_intltext_template("update_fail_eml.tpl");
89 $email_msg = replace_macros($email_tpl, array(
90 '$sitename' => $a->config['sitename'],
91 '$siteurl' => System::baseUrl(),
92 '$update' => DB_UPDATE_VERSION,
93 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
95 $subject=sprintf(t('Update Error at %s'), System::baseUrl());
96 require_once('include/email.php');
97 $subject = email_header_encode($subject,'UTF-8');
98 mail($a->config['admin_email'], $subject, $email_msg,
99 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
100 .'Content-type: text/plain; charset=UTF-8'."\n"
101 .'Content-transfer-encoding: 8bit');
104 logger("CRITICAL: Database structure update failed: ".$retval);
108 function table_structure($table) {
109 $structures = q("DESCRIBE `%s`", $table);
111 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
113 $indexes = q("SHOW INDEX FROM `%s`", $table);
115 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
117 if (dbm::is_result($table_status)) {
118 $table_status = $table_status[0];
120 $table_status = array();
123 $fielddata = array();
124 $indexdata = array();
126 if (dbm::is_result($indexes))
127 foreach ($indexes AS $index) {
128 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
129 $indexdata[$index["Key_name"]] = array('UNIQUE');
132 $column = $index["Column_name"];
134 if (($index["Sub_part"] != "")) {
135 $column .= "(".$index["Sub_part"].")";
138 $indexdata[$index["Key_name"]][] = $column;
140 if (dbm::is_result($structures)) {
141 foreach ($structures AS $field) {
142 $fielddata[$field["Field"]]["type"] = $field["Type"];
143 if ($field["Null"] == "NO") {
144 $fielddata[$field["Field"]]["not null"] = true;
147 if (isset($field["Default"])) {
148 $fielddata[$field["Field"]]["default"] = $field["Default"];
151 if ($field["Extra"] != "") {
152 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
155 if ($field["Key"] == "PRI") {
156 $fielddata[$field["Field"]]["primary"] = true;
160 if (dbm::is_result($full_columns)) {
161 foreach ($full_columns AS $column) {
162 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
166 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
169 function print_structure($database) {
170 echo "-- ------------------------------------------\n";
171 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
172 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
173 echo "-- ------------------------------------------\n\n\n";
174 foreach ($database AS $name => $structure) {
176 echo "-- TABLE $name\n";
178 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
185 * @brief Print out database error messages
187 * @param string $message Message to be added to the error message
189 * @return string Error message
191 function print_update_error($message) {
192 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
193 dba::errorNo(), dba::errorMessage());
195 return t('Errors encountered performing database changes: ').$message.EOL;
198 function update_structure($verbose, $action, $tables=null, $definition=null) {
202 Config::set('system', 'maintenance', 1);
203 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
208 logger('updating structure', LOGGER_DEBUG);
210 // Get the current structure
213 if (is_null($tables)) {
214 $tables = q("SHOW TABLES");
217 if (dbm::is_result($tables)) {
218 foreach ($tables AS $table) {
219 $table = current($table);
221 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
222 $database[$table] = table_structure($table);
226 // Get the definition
227 if (is_null($definition)) {
228 $definition = db_definition();
231 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
232 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
233 !(strpos(dba::server_info(), 'MariaDB') !== false)) {
240 foreach ($definition AS $name => $structure) {
241 $is_new_table = False;
244 if (!isset($database[$name])) {
245 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
246 if (!dbm::is_result($r)) {
247 $errors .= print_update_error($name);
249 $is_new_table = True;
254 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
255 if (isset($database[$name]["indexes"][$indexname])) {
256 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
258 $current_index_definition = "__NOT_SET__";
260 $new_index_definition = implode(",",$fieldnames);
261 if ($current_index_definition != $new_index_definition) {
262 if ($fieldnames[0] == "UNIQUE") {
265 $temp_name = "temp-".$name;
272 * Drop the index if it isn't present in the definition
273 * or the definition differ from current status
274 * and index name doesn't start with "local_"
276 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
277 $current_index_definition = implode(",",$fieldnames);
278 if (isset($structure["indexes"][$indexname])) {
279 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
281 $new_index_definition = "__NOT_SET__";
283 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
284 $sql2=db_drop_index($indexname);
286 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
292 // Compare the field structure field by field
293 foreach ($structure["fields"] AS $fieldname => $parameters) {
294 if (!isset($database[$name]["fields"][$fieldname])) {
295 $sql2=db_add_table_field($fieldname, $parameters);
297 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
302 // Compare the field definition
303 $field_definition = $database[$name]["fields"][$fieldname];
305 // Remove the relation data that is used for the referential integrity
306 unset($parameters['relation']);
308 // We change the collation after the indexes had been changed.
309 // This is done to avoid index length problems.
310 // So here we always ensure that there is no need to change it.
311 unset($parameters['Collation']);
312 unset($field_definition['Collation']);
314 $current_field_definition = implode(",", $field_definition);
315 $new_field_definition = implode(",", $parameters);
316 if ($current_field_definition != $new_field_definition) {
317 $sql2 = db_modify_table_field($fieldname, $parameters);
319 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
329 * Create the index if the index don't exists in database
330 * or the definition differ from the current status.
331 * Don't create keys if table is new
333 if (!$is_new_table) {
334 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
335 if (isset($database[$name]["indexes"][$indexname])) {
336 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
338 $current_index_definition = "__NOT_SET__";
340 $new_index_definition = implode(",",$fieldnames);
341 if ($current_index_definition != $new_index_definition) {
342 $sql2 = db_create_index($indexname, $fieldnames);
344 // Fetch the "group by" fields for unique indexes
345 if ($fieldnames[0] == "UNIQUE") {
346 $group_by = db_group_by($indexname, $fieldnames);
350 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
358 if (isset($database[$name]["table_status"]["Collation"])) {
359 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
360 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
363 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
374 // Now have a look at the field collations
375 // Compare the field structure field by field
376 foreach ($structure["fields"] AS $fieldname => $parameters) {
377 // Compare the field definition
378 $field_definition = $database[$name]["fields"][$fieldname];
380 // Define the default collation if not given
381 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
382 $parameters['Collation'] = 'utf8mb4_general_ci';
384 $parameters['Collation'] = null;
387 if ($field_definition['Collation'] != $parameters['Collation']) {
388 $sql2 = db_modify_table_field($fieldname, $parameters);
389 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
390 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
399 if (substr($sql3, -2, 2) != "; ") {
404 if ($is_unique && $ignore == '') {
405 foreach ($structure['fields'] AS $fieldname => $parameters) {
406 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
408 $field_list = rtrim($field_list, ',');
412 // Ensure index conversion to unique removes duplicates
413 if ($is_unique && ($temp_name != $name)) {
415 echo "SET session old_alter_table=1;\n";
417 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
418 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
424 if ($is_unique && ($temp_name != $name)) {
426 echo "SET session old_alter_table=0;\n";
428 echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
429 echo "DROP TABLE `".$name."`;\n";
430 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
436 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
438 // Ensure index conversion to unique removes duplicates
439 if ($is_unique && ($temp_name != $name)) {
441 dba::e("SET session old_alter_table=1;");
443 dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
444 if (!dbm::is_result($r)) {
445 $errors .= print_update_error($sql3);
449 $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
450 if (!dbm::is_result($r)) {
451 $errors .= print_update_error($sql3);
458 if (!dbm::is_result($r)) {
459 $errors .= print_update_error($sql3);
461 if ($is_unique && ($temp_name != $name)) {
463 dba::e("SET session old_alter_table=0;");
465 $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
466 if (!dbm::is_result($r)) {
467 $errors .= print_update_error($sql3);
470 $r = dba::e("DROP TABLE `".$name."`;");
471 if (!dbm::is_result($r)) {
472 $errors .= print_update_error($sql3);
475 $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
476 if (!dbm::is_result($r)) {
477 $errors .= print_update_error($sql3);
487 Config::set('system', 'maintenance', 0);
488 Config::set('system', 'maintenance_reason', '');
492 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
494 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
500 function db_field_command($parameters, $create = true) {
501 $fieldstruct = $parameters["type"];
503 if (!is_null($parameters["Collation"])) {
504 $fieldstruct .= " COLLATE ".$parameters["Collation"];
507 if ($parameters["not null"])
508 $fieldstruct .= " NOT NULL";
510 if (isset($parameters["default"])) {
511 if (strpos(strtolower($parameters["type"]),"int")!==false) {
512 $fieldstruct .= " DEFAULT ".$parameters["default"];
514 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
517 if ($parameters["extra"] != "")
518 $fieldstruct .= " ".$parameters["extra"];
520 /*if (($parameters["primary"] != "") && $create)
521 $fieldstruct .= " PRIMARY KEY";*/
523 return($fieldstruct);
526 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
534 $primary_keys = array();
535 foreach ($fields AS $fieldname => $field) {
536 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
537 if (x($field,'primary') && $field['primary']!='') {
538 $primary_keys[] = $fieldname;
542 if (!is_null($indexes)) {
543 foreach ($indexes AS $indexname => $fieldnames) {
544 $sql_index = db_create_index($indexname, $fieldnames, "");
545 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
549 $sql = implode(",\n\t", $sql_rows);
551 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
561 function db_add_table_field($fieldname, $parameters) {
562 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
566 function db_modify_table_field($fieldname, $parameters) {
567 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
571 function db_drop_index($indexname) {
572 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
576 function db_create_index($indexname, $fieldnames, $method="ADD") {
578 $method = strtoupper(trim($method));
579 if ($method!="" && $method!="ADD") {
580 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
584 if ($fieldnames[0] == "UNIQUE") {
585 array_shift($fieldnames);
586 $method .= ' UNIQUE';
590 foreach ($fieldnames AS $fieldname) {
594 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
595 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
597 $names .= "`".dbesc($fieldname)."`";
601 if ($indexname == "PRIMARY") {
602 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
606 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
610 function db_group_by($indexname, $fieldnames) {
612 if ($fieldnames[0] != "UNIQUE") {
616 array_shift($fieldnames);
619 foreach ($fieldnames AS $fieldname) {
623 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
624 $names .= "`".dbesc($matches[1])."`";
626 $names .= "`".dbesc($fieldname)."`";
630 $sql = sprintf(" GROUP BY %s", $names);
634 function db_definition() {
638 $database["addon"] = array(
640 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
641 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
642 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
643 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
644 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
645 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
646 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
649 "PRIMARY" => array("id"),
650 "name" => array("UNIQUE", "name"),
653 $database["attach"] = array(
655 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
656 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
657 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
658 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
659 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
660 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
661 "data" => array("type" => "longblob", "not null" => "1"),
662 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
663 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
664 "allow_cid" => array("type" => "mediumtext"),
665 "allow_gid" => array("type" => "mediumtext"),
666 "deny_cid" => array("type" => "mediumtext"),
667 "deny_gid" => array("type" => "mediumtext"),
670 "PRIMARY" => array("id"),
673 $database["auth_codes"] = array(
675 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
676 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
677 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
678 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
679 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
682 "PRIMARY" => array("id"),
685 $database["cache"] = array(
687 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
688 "v" => array("type" => "mediumtext"),
689 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
690 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
693 "PRIMARY" => array("k"),
694 "expire_mode_updated" => array("expire_mode", "updated"),
697 $database["challenge"] = array(
699 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
700 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
701 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
702 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
703 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
704 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
707 "PRIMARY" => array("id"),
710 $database["clients"] = array(
712 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
713 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
714 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
715 "name" => array("type" => "text"),
716 "icon" => array("type" => "text"),
717 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
720 "PRIMARY" => array("client_id"),
723 $database["config"] = array(
725 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
726 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
727 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
728 "v" => array("type" => "mediumtext"),
731 "PRIMARY" => array("id"),
732 "cat_k" => array("UNIQUE", "cat", "k"),
735 $database["contact"] = array(
737 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
738 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
739 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
740 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
741 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
742 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
743 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
744 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "about" => array("type" => "text"),
749 "keywords" => array("type" => "text"),
750 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
751 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
753 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754 "photo" => array("type" => "text"),
755 "thumb" => array("type" => "text"),
756 "micro" => array("type" => "text"),
757 "site-pubkey" => array("type" => "text"),
758 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
761 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
762 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
763 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
764 "pubkey" => array("type" => "text"),
765 "prvkey" => array("type" => "text"),
766 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
767 "request" => array("type" => "text"),
768 "notify" => array("type" => "text"),
769 "poll" => array("type" => "text"),
770 "confirm" => array("type" => "text"),
771 "poco" => array("type" => "text"),
772 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
775 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
776 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
777 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
778 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
779 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
780 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
781 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
782 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
783 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
784 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
785 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
786 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
787 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
790 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
792 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
793 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
794 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
795 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
796 "reason" => array("type" => "text"),
797 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
798 "info" => array("type" => "mediumtext"),
799 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
800 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
801 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
802 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
803 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
804 "ffi_keyword_blacklist" => array("type" => "text"),
807 "PRIMARY" => array("id"),
808 "uid_name" => array("uid", "name(190)"),
809 "self_uid" => array("self", "uid"),
810 "alias_uid" => array("alias(32)", "uid"),
811 "pending_uid" => array("pending", "uid"),
812 "blocked_uid" => array("blocked", "uid"),
813 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
814 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
815 "addr_uid" => array("addr(32)", "uid"),
816 "nurl_uid" => array("nurl(32)", "uid"),
817 "nick_uid" => array("nick(32)", "uid"),
818 "dfrn-id" => array("dfrn-id(64)"),
819 "issued-id" => array("issued-id(64)"),
822 $database["conv"] = array(
824 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
825 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
826 "recips" => array("type" => "text"),
827 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
828 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
829 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
830 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
831 "subject" => array("type" => "text"),
834 "PRIMARY" => array("id"),
835 "uid" => array("uid"),
838 $database["conversation"] = array(
840 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
841 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
842 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
843 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
844 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
845 "source" => array("type" => "mediumtext"),
846 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
849 "PRIMARY" => array("item-uri"),
850 "conversation-uri" => array("conversation-uri"),
853 $database["event"] = array(
855 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
856 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
857 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
858 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
859 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
860 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
861 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
862 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
863 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
864 "summary" => array("type" => "text"),
865 "desc" => array("type" => "text"),
866 "location" => array("type" => "text"),
867 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
868 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
869 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
870 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
871 "allow_cid" => array("type" => "mediumtext"),
872 "allow_gid" => array("type" => "mediumtext"),
873 "deny_cid" => array("type" => "mediumtext"),
874 "deny_gid" => array("type" => "mediumtext"),
877 "PRIMARY" => array("id"),
878 "uid_start" => array("uid", "start"),
881 $database["fcontact"] = array(
883 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
884 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
885 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
886 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
889 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
892 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
893 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
894 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
895 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
896 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
897 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
898 "pubkey" => array("type" => "text"),
899 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
902 "PRIMARY" => array("id"),
903 "addr" => array("addr(32)"),
904 "url" => array("UNIQUE", "url(190)"),
907 $database["ffinder"] = array(
909 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
910 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
911 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
912 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
915 "PRIMARY" => array("id"),
918 $database["fserver"] = array(
920 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
921 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
922 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
923 "key" => array("type" => "text"),
926 "PRIMARY" => array("id"),
927 "server" => array("server(32)"),
930 $database["fsuggest"] = array(
932 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
933 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
934 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
935 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
936 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
937 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
938 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
939 "note" => array("type" => "text"),
940 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
943 "PRIMARY" => array("id"),
946 $database["gcign"] = array(
948 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
949 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
950 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
953 "PRIMARY" => array("id"),
954 "uid" => array("uid"),
955 "gcid" => array("gcid"),
958 $database["gcontact"] = array(
960 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
961 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
963 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
964 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
965 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
966 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
967 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
968 "updated" => array("type" => "datetime", "default" => NULL_DATE),
969 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
970 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
971 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
972 "about" => array("type" => "text"),
973 "keywords" => array("type" => "text"),
974 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
975 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
976 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
977 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
978 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
979 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
980 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
981 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
982 "notify" => array("type" => "text"),
983 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
984 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
985 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
988 "PRIMARY" => array("id"),
989 "nurl" => array("UNIQUE", "nurl(190)"),
990 "name" => array("name(64)"),
991 "nick" => array("nick(32)"),
992 "addr" => array("addr(64)"),
993 "hide_network_updated" => array("hide", "network(4)", "updated"),
994 "updated" => array("updated"),
997 $database["glink"] = array(
999 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1000 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1001 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1002 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1003 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1004 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1007 "PRIMARY" => array("id"),
1008 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
1009 "gcid" => array("gcid"),
1012 $database["group"] = array(
1014 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1015 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1016 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1017 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1018 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1021 "PRIMARY" => array("id"),
1022 "uid" => array("uid"),
1025 $database["group_member"] = array(
1027 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1028 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1029 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1030 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1033 "PRIMARY" => array("id"),
1034 "contactid" => array("contact-id"),
1035 "gid_contactid" => array("gid", "contact-id"),
1036 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1039 $database["gserver"] = array(
1041 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1042 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "info" => array("type" => "text"),
1047 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1048 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1050 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1051 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1052 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1053 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1054 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1055 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1058 "PRIMARY" => array("id"),
1059 "nurl" => array("UNIQUE", "nurl(190)"),
1062 $database["hook"] = array(
1064 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1065 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1066 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1067 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1068 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1071 "PRIMARY" => array("id"),
1072 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1075 $database["intro"] = array(
1077 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1078 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1079 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1080 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1081 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1082 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1083 "note" => array("type" => "text"),
1084 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1085 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1086 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1087 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1090 "PRIMARY" => array("id"),
1093 $database["item"] = array(
1095 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1096 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1097 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1098 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1099 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1100 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1101 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1102 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1103 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1104 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1105 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1107 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1108 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1109 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1110 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1111 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1112 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1113 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1114 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1115 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1118 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1119 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1120 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1121 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1122 "body" => array("type" => "mediumtext"),
1123 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1124 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1125 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1126 "object" => array("type" => "text"),
1127 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1128 "target" => array("type" => "text"),
1129 "postopts" => array("type" => "text"),
1130 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1131 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1132 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1133 "tag" => array("type" => "mediumtext"),
1134 "attach" => array("type" => "mediumtext"),
1135 "inform" => array("type" => "mediumtext"),
1136 "file" => array("type" => "mediumtext"),
1137 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1138 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1139 "allow_cid" => array("type" => "mediumtext"),
1140 "allow_gid" => array("type" => "mediumtext"),
1141 "deny_cid" => array("type" => "mediumtext"),
1142 "deny_gid" => array("type" => "mediumtext"),
1143 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1144 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1145 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1146 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1147 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1148 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1149 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1150 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1151 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1152 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1153 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1154 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1155 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1156 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1157 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1158 "rendered-html" => array("type" => "mediumtext"),
1159 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1162 "PRIMARY" => array("id"),
1163 "guid" => array("guid(191)"),
1164 "uri" => array("uri(191)"),
1165 "parent" => array("parent"),
1166 "parent-uri" => array("parent-uri(191)"),
1167 "extid" => array("extid(191)"),
1168 "uid_id" => array("uid","id"),
1169 "uid_contactid_id" => array("uid","contact-id","id"),
1170 "uid_created" => array("uid","created"),
1171 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1172 "uid_network_received" => array("uid","network(4)","received"),
1173 "uid_network_commented" => array("uid","network(4)","commented"),
1174 "uid_thrparent" => array("uid","thr-parent(190)"),
1175 "uid_parenturi" => array("uid","parent-uri(190)"),
1176 "uid_contactid_created" => array("uid","contact-id","created"),
1177 "authorid_created" => array("author-id","created"),
1178 "ownerid" => array("owner-id"),
1179 "uid_uri" => array("uid", "uri(190)"),
1180 "resource-id" => array("resource-id(191)"),
1181 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1182 "uid_type_changed" => array("uid","type(190)","changed"),
1183 "contactid_verb" => array("contact-id","verb(190)"),
1184 "deleted_changed" => array("deleted","changed"),
1185 "uid_wall_changed" => array("uid","wall","changed"),
1186 "uid_eventid" => array("uid","event-id"),
1187 "uid_authorlink" => array("uid","author-link(190)"),
1188 "uid_ownerlink" => array("uid","owner-link(190)"),
1191 $database["item_id"] = array(
1193 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1194 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1195 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1196 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1197 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1200 "PRIMARY" => array("id"),
1201 "uid" => array("uid"),
1202 "sid" => array("sid(32)"),
1203 "service" => array("service(32)"),
1204 "iid" => array("iid"),
1207 $database["locks"] = array(
1209 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1210 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1211 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1212 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1215 "PRIMARY" => array("id"),
1218 $database["mail"] = array(
1220 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1221 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1222 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1223 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1224 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1225 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1226 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1227 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1228 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1229 "body" => array("type" => "mediumtext"),
1230 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1231 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1232 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1233 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1234 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1235 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1236 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1239 "PRIMARY" => array("id"),
1240 "uid_seen" => array("uid", "seen"),
1241 "convid" => array("convid"),
1242 "uri" => array("uri(64)"),
1243 "parent-uri" => array("parent-uri(64)"),
1244 "contactid" => array("contact-id(32)"),
1247 $database["mailacct"] = array(
1249 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1250 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1251 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1252 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1253 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1254 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1255 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1256 "pass" => array("type" => "text"),
1257 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1258 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1259 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1260 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1261 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1264 "PRIMARY" => array("id"),
1267 $database["manage"] = array(
1269 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1270 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1271 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1274 "PRIMARY" => array("id"),
1275 "uid_mid" => array("UNIQUE", "uid","mid"),
1278 $database["notify"] = array(
1280 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1281 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1282 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1283 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1284 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1285 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1286 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1287 "msg" => array("type" => "mediumtext"),
1288 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1289 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1290 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1291 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1292 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1293 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1294 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1295 "name_cache" => array("type" => "tinytext"),
1296 "msg_cache" => array("type" => "mediumtext")
1299 "PRIMARY" => array("id"),
1300 "hash_uid" => array("hash", "uid"),
1301 "seen_uid_date" => array("seen", "uid", "date"),
1302 "uid_date" => array("uid", "date"),
1303 "uid_type_link" => array("uid", "type", "link(190)"),
1306 $database["notify-threads"] = array(
1308 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1309 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1310 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1311 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1312 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1315 "PRIMARY" => array("id"),
1318 $database["oembed"] = array(
1320 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1321 "content" => array("type" => "mediumtext"),
1322 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1325 "PRIMARY" => array("url"),
1326 "created" => array("created"),
1329 $database["parsed_url"] = array(
1331 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1332 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1333 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1334 "content" => array("type" => "mediumtext"),
1335 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1338 "PRIMARY" => array("url", "guessing", "oembed"),
1339 "created" => array("created"),
1342 $database["pconfig"] = array(
1344 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1345 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1346 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1347 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1348 "v" => array("type" => "mediumtext"),
1351 "PRIMARY" => array("id"),
1352 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1355 $database["photo"] = array(
1357 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1358 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1359 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1360 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1361 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1362 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1363 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1364 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1365 "desc" => array("type" => "text"),
1366 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1367 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1368 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1369 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1370 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1371 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1372 "data" => array("type" => "mediumblob", "not null" => "1"),
1373 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1374 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1375 "allow_cid" => array("type" => "mediumtext"),
1376 "allow_gid" => array("type" => "mediumtext"),
1377 "deny_cid" => array("type" => "mediumtext"),
1378 "deny_gid" => array("type" => "mediumtext"),
1381 "PRIMARY" => array("id"),
1382 "contactid" => array("contact-id"),
1383 "uid_contactid" => array("uid", "contact-id"),
1384 "uid_profile" => array("uid", "profile"),
1385 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1386 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1387 "resource-id" => array("resource-id(64)"),
1390 $database["poll"] = array(
1392 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1393 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1394 "q0" => array("type" => "text"),
1395 "q1" => array("type" => "text"),
1396 "q2" => array("type" => "text"),
1397 "q3" => array("type" => "text"),
1398 "q4" => array("type" => "text"),
1399 "q5" => array("type" => "text"),
1400 "q6" => array("type" => "text"),
1401 "q7" => array("type" => "text"),
1402 "q8" => array("type" => "text"),
1403 "q9" => array("type" => "text"),
1406 "PRIMARY" => array("id"),
1407 "uid" => array("uid"),
1410 $database["poll_result"] = array(
1412 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1413 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1414 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1417 "PRIMARY" => array("id"),
1418 "poll_id" => array("poll_id"),
1419 "choice" => array("choice"),
1422 $database["process"] = array(
1424 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1425 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1426 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1429 "PRIMARY" => array("pid"),
1430 "command" => array("command"),
1433 $database["profile"] = array(
1435 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1436 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1437 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1438 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1439 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1440 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1441 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1442 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1443 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1444 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1445 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1446 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1447 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1448 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1449 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1450 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1451 "with" => array("type" => "text"),
1452 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1453 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1454 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1455 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1456 "pub_keywords" => array("type" => "text"),
1457 "prv_keywords" => array("type" => "text"),
1458 "likes" => array("type" => "text"),
1459 "dislikes" => array("type" => "text"),
1460 "about" => array("type" => "text"),
1461 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1462 "music" => array("type" => "text"),
1463 "book" => array("type" => "text"),
1464 "tv" => array("type" => "text"),
1465 "film" => array("type" => "text"),
1466 "interest" => array("type" => "text"),
1467 "romance" => array("type" => "text"),
1468 "work" => array("type" => "text"),
1469 "education" => array("type" => "text"),
1470 "contact" => array("type" => "text"),
1471 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1472 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1473 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1474 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1475 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1476 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1479 "PRIMARY" => array("id"),
1480 "uid_is-default" => array("uid", "is-default"),
1483 $database["profile_check"] = array(
1485 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1486 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1487 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1488 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1489 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1490 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1493 "PRIMARY" => array("id"),
1496 $database["push_subscriber"] = array(
1498 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1499 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1500 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1501 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1502 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1503 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1504 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1505 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1508 "PRIMARY" => array("id"),
1511 $database["queue"] = array(
1513 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1514 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1515 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1516 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1517 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1518 "content" => array("type" => "mediumtext"),
1519 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1522 "PRIMARY" => array("id"),
1523 "cid" => array("cid"),
1524 "created" => array("created"),
1525 "last" => array("last"),
1526 "network" => array("network"),
1527 "batch" => array("batch"),
1530 $database["register"] = array(
1532 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1533 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1534 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1535 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1536 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1537 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1538 "note" => array("type" => "text"),
1541 "PRIMARY" => array("id"),
1544 $database["search"] = array(
1546 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1547 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1548 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1551 "PRIMARY" => array("id"),
1552 "uid" => array("uid"),
1555 $database["session"] = array(
1557 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1558 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1559 "data" => array("type" => "text"),
1560 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1563 "PRIMARY" => array("id"),
1564 "sid" => array("sid(64)"),
1565 "expire" => array("expire"),
1568 $database["sign"] = array(
1570 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1571 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1572 "signed_text" => array("type" => "mediumtext"),
1573 "signature" => array("type" => "text"),
1574 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1577 "PRIMARY" => array("id"),
1578 "iid" => array("UNIQUE", "iid"),
1581 $database["spam"] = array(
1583 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1584 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1585 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1586 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1587 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1588 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1591 "PRIMARY" => array("id"),
1592 "uid" => array("uid"),
1593 "spam" => array("spam"),
1594 "ham" => array("ham"),
1595 "term" => array("term(32)"),
1598 $database["term"] = array(
1600 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1601 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1602 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1603 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1604 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1605 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1606 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1607 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1608 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1609 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1610 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1611 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1614 "PRIMARY" => array("tid"),
1615 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1616 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1617 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1618 "guid" => array("guid(64)"),
1621 $database["thread"] = array(
1623 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1624 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1625 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1626 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1627 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1628 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1629 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1630 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1631 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1632 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1633 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1634 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1635 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1636 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1637 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1638 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1639 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1640 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1641 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1642 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1643 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1644 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1645 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1646 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1647 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1648 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1651 "PRIMARY" => array("iid"),
1652 "uid_network_commented" => array("uid","network","commented"),
1653 "uid_network_created" => array("uid","network","created"),
1654 "uid_contactid_commented" => array("uid","contact-id","commented"),
1655 "uid_contactid_created" => array("uid","contact-id","created"),
1656 "contactid" => array("contact-id"),
1657 "ownerid" => array("owner-id"),
1658 "authorid" => array("author-id"),
1659 "uid_created" => array("uid","created"),
1660 "uid_commented" => array("uid","commented"),
1661 "uid_wall_created" => array("uid","wall","created"),
1662 "private_wall_received" => array("private","wall","received"),
1665 $database["tokens"] = array(
1667 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1668 "secret" => array("type" => "text"),
1669 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1670 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1671 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1672 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1675 "PRIMARY" => array("id"),
1678 $database["user"] = array(
1680 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1681 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1682 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1683 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1684 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1685 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1686 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1687 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1688 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1689 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1690 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1691 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1692 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1693 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1694 "pubkey" => array("type" => "text"),
1695 "prvkey" => array("type" => "text"),
1696 "spubkey" => array("type" => "text"),
1697 "sprvkey" => array("type" => "text"),
1698 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1699 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1700 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1701 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1702 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1703 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1704 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1705 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1706 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1707 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1708 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1709 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1710 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1711 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1712 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1713 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1714 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1715 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1716 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1717 "allow_cid" => array("type" => "mediumtext"),
1718 "allow_gid" => array("type" => "mediumtext"),
1719 "deny_cid" => array("type" => "mediumtext"),
1720 "deny_gid" => array("type" => "mediumtext"),
1721 "openidserver" => array("type" => "text"),
1724 "PRIMARY" => array("uid"),
1725 "nickname" => array("nickname(32)"),
1728 $database["userd"] = array(
1730 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1731 "username" => array("type" => "varchar(255)", "not null" => "1"),
1734 "PRIMARY" => array("id"),
1735 "username" => array("username(32)"),
1738 $database["workerqueue"] = array(
1740 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1741 "parameter" => array("type" => "text"),
1742 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1743 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1744 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1745 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1746 "done" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1749 "PRIMARY" => array("id"),
1750 "pid" => array("pid"),
1751 "parameter" => array("parameter(64)"),
1752 "priority_created" => array("priority", "created"),
1753 "executed" => array("executed"),
1762 * run from command line
1764 function dbstructure_run(&$argv, &$argc) {
1768 $a = new App(dirname(__DIR__));
1771 @include ".htconfig.php";
1772 require_once "include/dba.php";
1773 dba::connect($db_host, $db_user, $db_pass, $db_data);
1774 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"]);