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"];
133 // On utf8mb4 a varchar index can only have a length of 191
134 // The "show index" command sometimes returns this value although this value wasn't added manually.
135 // Because we don't want to add this number to every index, we ignore bigger numbers
136 if (($index["Sub_part"] != "") && (($index["Sub_part"] < 191) || ($index["Key_name"] == "PRIMARY"))) {
137 $column .= "(".$index["Sub_part"].")";
140 $indexdata[$index["Key_name"]][] = $column;
142 if (dbm::is_result($structures)) {
143 foreach ($structures AS $field) {
144 $fielddata[$field["Field"]]["type"] = $field["Type"];
145 if ($field["Null"] == "NO") {
146 $fielddata[$field["Field"]]["not null"] = true;
149 if (isset($field["Default"])) {
150 $fielddata[$field["Field"]]["default"] = $field["Default"];
153 if ($field["Extra"] != "") {
154 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
157 if ($field["Key"] == "PRI") {
158 $fielddata[$field["Field"]]["primary"] = true;
162 if (dbm::is_result($full_columns)) {
163 foreach ($full_columns AS $column) {
164 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
168 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
171 function print_structure($database) {
172 echo "-- ------------------------------------------\n";
173 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
174 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
175 echo "-- ------------------------------------------\n\n\n";
176 foreach ($database AS $name => $structure) {
178 echo "-- TABLE $name\n";
180 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
187 * @brief Print out database error messages
189 * @param string $message Message to be added to the error message
191 * @return string Error message
193 function print_update_error($message) {
194 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
195 dba::errorNo(), dba::errorMessage());
197 return t('Errors encountered performing database changes: ').$message.EOL;
200 function update_structure($verbose, $action, $tables=null, $definition=null) {
204 Config::set('system', 'maintenance', 1);
205 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
210 logger('updating structure', LOGGER_DEBUG);
212 // Get the current structure
215 if (is_null($tables)) {
216 $tables = q("SHOW TABLES");
219 if (dbm::is_result($tables)) {
220 foreach ($tables AS $table) {
221 $table = current($table);
223 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
224 $database[$table] = table_structure($table);
228 // Get the definition
229 if (is_null($definition)) {
230 $definition = db_definition();
233 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
234 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
235 !(strpos(dba::server_info(), 'MariaDB') !== false)) {
242 foreach ($definition AS $name => $structure) {
243 $is_new_table = False;
246 if (!isset($database[$name])) {
247 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
248 if (!dbm::is_result($r)) {
249 $errors .= print_update_error($name);
251 $is_new_table = True;
256 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
257 if (isset($database[$name]["indexes"][$indexname])) {
258 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
260 $current_index_definition = "__NOT_SET__";
262 $new_index_definition = implode(",",$fieldnames);
263 if ($current_index_definition != $new_index_definition) {
264 if ($fieldnames[0] == "UNIQUE") {
267 $temp_name = "temp-".$name;
274 * Drop the index if it isn't present in the definition
275 * or the definition differ from current status
276 * and index name doesn't start with "local_"
278 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
279 $current_index_definition = implode(",",$fieldnames);
280 if (isset($structure["indexes"][$indexname])) {
281 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
283 $new_index_definition = "__NOT_SET__";
285 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
286 $sql2=db_drop_index($indexname);
288 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
294 // Compare the field structure field by field
295 foreach ($structure["fields"] AS $fieldname => $parameters) {
296 if (!isset($database[$name]["fields"][$fieldname])) {
297 $sql2=db_add_table_field($fieldname, $parameters);
299 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
304 // Compare the field definition
305 $field_definition = $database[$name]["fields"][$fieldname];
307 // Remove the relation data that is used for the referential integrity
308 unset($parameters['relation']);
310 // We change the collation after the indexes had been changed.
311 // This is done to avoid index length problems.
312 // So here we always ensure that there is no need to change it.
313 unset($parameters['Collation']);
314 unset($field_definition['Collation']);
316 $current_field_definition = implode(",", $field_definition);
317 $new_field_definition = implode(",", $parameters);
318 if ($current_field_definition != $new_field_definition) {
319 $sql2 = db_modify_table_field($fieldname, $parameters);
321 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
331 * Create the index if the index don't exists in database
332 * or the definition differ from the current status.
333 * Don't create keys if table is new
335 if (!$is_new_table) {
336 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
337 if (isset($database[$name]["indexes"][$indexname])) {
338 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
340 $current_index_definition = "__NOT_SET__";
342 $new_index_definition = implode(",",$fieldnames);
343 if ($current_index_definition != $new_index_definition) {
344 $sql2 = db_create_index($indexname, $fieldnames);
346 // Fetch the "group by" fields for unique indexes
347 if ($fieldnames[0] == "UNIQUE") {
348 $group_by = db_group_by($indexname, $fieldnames);
352 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
360 if (isset($database[$name]["table_status"]["Collation"])) {
361 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
362 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
365 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
376 // Now have a look at the field collations
377 // Compare the field structure field by field
378 foreach ($structure["fields"] AS $fieldname => $parameters) {
379 // Compare the field definition
380 $field_definition = $database[$name]["fields"][$fieldname];
382 // Define the default collation if not given
383 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
384 $parameters['Collation'] = 'utf8mb4_general_ci';
386 $parameters['Collation'] = null;
389 if ($field_definition['Collation'] != $parameters['Collation']) {
390 $sql2 = db_modify_table_field($fieldname, $parameters);
391 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
392 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
401 if (substr($sql3, -2, 2) != "; ") {
406 if ($is_unique && $ignore == '') {
407 foreach ($structure['fields'] AS $fieldname => $parameters) {
408 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
410 $field_list = rtrim($field_list, ',');
414 // Ensure index conversion to unique removes duplicates
417 echo "SET session old_alter_table=1;\n";
419 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
427 echo "SET session old_alter_table=0;\n";
429 echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
430 echo "DROP TABLE `".$name."`;\n";
431 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
437 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
439 // Ensure index conversion to unique removes duplicates
442 dba::e("SET session old_alter_table=1;");
444 $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
445 if (!dbm::is_result($r)) {
446 $errors .= print_update_error($sql3);
453 if (!dbm::is_result($r)) {
454 $errors .= print_update_error($sql3);
458 dba::e("SET session old_alter_table=0;");
460 $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
461 if (!dbm::is_result($r)) {
462 $errors .= print_update_error($sql3);
465 $r = dba::e("DROP TABLE `".$name."`;");
466 if (!dbm::is_result($r)) {
467 $errors .= print_update_error($sql3);
470 $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
471 if (!dbm::is_result($r)) {
472 $errors .= print_update_error($sql3);
482 Config::set('system', 'maintenance', 0);
483 Config::set('system', 'maintenance_reason', '');
487 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
489 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
495 function db_field_command($parameters, $create = true) {
496 $fieldstruct = $parameters["type"];
498 if (!is_null($parameters["Collation"])) {
499 $fieldstruct .= " COLLATE ".$parameters["Collation"];
502 if ($parameters["not null"])
503 $fieldstruct .= " NOT NULL";
505 if (isset($parameters["default"])) {
506 if (strpos(strtolower($parameters["type"]),"int")!==false) {
507 $fieldstruct .= " DEFAULT ".$parameters["default"];
509 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
512 if ($parameters["extra"] != "")
513 $fieldstruct .= " ".$parameters["extra"];
515 /*if (($parameters["primary"] != "") && $create)
516 $fieldstruct .= " PRIMARY KEY";*/
518 return($fieldstruct);
521 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
529 $primary_keys = array();
530 foreach ($fields AS $fieldname => $field) {
531 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
532 if (x($field,'primary') && $field['primary']!='') {
533 $primary_keys[] = $fieldname;
537 if (!is_null($indexes)) {
538 foreach ($indexes AS $indexname => $fieldnames) {
539 $sql_index = db_create_index($indexname, $fieldnames, "");
540 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
544 $sql = implode(",\n\t", $sql_rows);
546 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
556 function db_add_table_field($fieldname, $parameters) {
557 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
561 function db_modify_table_field($fieldname, $parameters) {
562 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
566 function db_drop_index($indexname) {
567 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
571 function db_create_index($indexname, $fieldnames, $method="ADD") {
573 $method = strtoupper(trim($method));
574 if ($method!="" && $method!="ADD") {
575 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
579 if ($fieldnames[0] == "UNIQUE") {
580 array_shift($fieldnames);
581 $method .= ' UNIQUE';
585 foreach ($fieldnames AS $fieldname) {
589 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
590 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
592 $names .= "`".dbesc($fieldname)."`";
596 if ($indexname == "PRIMARY") {
597 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
601 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
605 function db_group_by($indexname, $fieldnames) {
607 if ($fieldnames[0] != "UNIQUE") {
611 array_shift($fieldnames);
614 foreach ($fieldnames AS $fieldname) {
618 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
619 $names .= "`".dbesc($matches[1])."`";
621 $names .= "`".dbesc($fieldname)."`";
625 $sql = sprintf(" GROUP BY %s", $names);
629 function db_definition() {
633 $database["addon"] = array(
635 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
636 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
637 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
638 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
639 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
640 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
641 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
644 "PRIMARY" => array("id"),
645 "name" => array("UNIQUE", "name"),
648 $database["attach"] = array(
650 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
651 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
652 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
653 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
654 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
655 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
656 "data" => array("type" => "longblob", "not null" => "1"),
657 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
658 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
659 "allow_cid" => array("type" => "mediumtext"),
660 "allow_gid" => array("type" => "mediumtext"),
661 "deny_cid" => array("type" => "mediumtext"),
662 "deny_gid" => array("type" => "mediumtext"),
665 "PRIMARY" => array("id"),
668 $database["auth_codes"] = array(
670 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
671 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
672 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
673 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
674 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
677 "PRIMARY" => array("id"),
680 $database["cache"] = array(
682 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
683 "v" => array("type" => "mediumtext"),
684 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
685 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
688 "PRIMARY" => array("k"),
689 "expire_mode_updated" => array("expire_mode", "updated"),
692 $database["challenge"] = array(
694 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
695 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
696 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
697 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
698 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
702 "PRIMARY" => array("id"),
705 $database["clients"] = array(
707 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
708 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
709 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
710 "name" => array("type" => "text"),
711 "icon" => array("type" => "text"),
712 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
715 "PRIMARY" => array("client_id"),
718 $database["config"] = array(
720 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
721 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
722 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
723 "v" => array("type" => "mediumtext"),
726 "PRIMARY" => array("id"),
727 "cat_k" => array("UNIQUE", "cat", "k"),
730 $database["contact"] = array(
732 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
733 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
734 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
735 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
736 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
737 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
738 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
739 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
741 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "about" => array("type" => "text"),
744 "keywords" => array("type" => "text"),
745 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
746 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "photo" => array("type" => "text"),
750 "thumb" => array("type" => "text"),
751 "micro" => array("type" => "text"),
752 "site-pubkey" => array("type" => "text"),
753 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "pubkey" => array("type" => "text"),
760 "prvkey" => array("type" => "text"),
761 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
762 "request" => array("type" => "text"),
763 "notify" => array("type" => "text"),
764 "poll" => array("type" => "text"),
765 "confirm" => array("type" => "text"),
766 "poco" => array("type" => "text"),
767 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
768 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
769 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
770 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
772 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
773 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
774 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
775 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
776 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
777 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
778 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
779 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
780 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
781 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
782 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
783 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
784 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
785 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
786 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
787 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
790 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791 "reason" => array("type" => "text"),
792 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
793 "info" => array("type" => "mediumtext"),
794 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
795 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
796 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
797 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
798 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
799 "ffi_keyword_blacklist" => array("type" => "text"),
802 "PRIMARY" => array("id"),
803 "uid_name" => array("uid", "name(190)"),
804 "self_uid" => array("self", "uid"),
805 "alias_uid" => array("alias(32)", "uid"),
806 "pending_uid" => array("pending", "uid"),
807 "blocked_uid" => array("blocked", "uid"),
808 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
809 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
810 "addr_uid" => array("addr(32)", "uid"),
811 "nurl_uid" => array("nurl(32)", "uid"),
812 "nick_uid" => array("nick(32)", "uid"),
813 "dfrn-id" => array("dfrn-id"),
814 "issued-id" => array("issued-id"),
817 $database["conv"] = array(
819 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
820 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
821 "recips" => array("type" => "text"),
822 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
823 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
824 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
825 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
826 "subject" => array("type" => "text"),
829 "PRIMARY" => array("id"),
830 "uid" => array("uid"),
833 $database["conversation"] = array(
835 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
836 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
837 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
838 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
839 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
840 "source" => array("type" => "mediumtext"),
841 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
844 "PRIMARY" => array("item-uri"),
845 "conversation-uri" => array("conversation-uri"),
848 $database["event"] = array(
850 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
851 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
852 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
853 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
854 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
855 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
856 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
857 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
858 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
859 "summary" => array("type" => "text"),
860 "desc" => array("type" => "text"),
861 "location" => array("type" => "text"),
862 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
863 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
864 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
865 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
866 "allow_cid" => array("type" => "mediumtext"),
867 "allow_gid" => array("type" => "mediumtext"),
868 "deny_cid" => array("type" => "mediumtext"),
869 "deny_gid" => array("type" => "mediumtext"),
872 "PRIMARY" => array("id"),
873 "uid_start" => array("uid", "start"),
876 $database["fcontact"] = array(
878 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
879 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
880 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
881 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
882 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
883 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
885 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
886 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
889 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
891 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
892 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
893 "pubkey" => array("type" => "text"),
894 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
897 "PRIMARY" => array("id"),
898 "addr" => array("addr(32)"),
899 "url" => array("UNIQUE", "url(190)"),
902 $database["ffinder"] = array(
904 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
905 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
906 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
907 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
910 "PRIMARY" => array("id"),
913 $database["fserver"] = array(
915 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
916 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
917 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
918 "key" => array("type" => "text"),
921 "PRIMARY" => array("id"),
922 "server" => array("server(32)"),
925 $database["fsuggest"] = array(
927 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
928 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
929 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
930 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
931 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
932 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
933 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
934 "note" => array("type" => "text"),
935 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
938 "PRIMARY" => array("id"),
941 $database["gcign"] = array(
943 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
944 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
945 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
948 "PRIMARY" => array("id"),
949 "uid" => array("uid"),
950 "gcid" => array("gcid"),
953 $database["gcontact"] = array(
955 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
956 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
957 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
963 "updated" => array("type" => "datetime", "default" => NULL_DATE),
964 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
965 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
966 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
967 "about" => array("type" => "text"),
968 "keywords" => array("type" => "text"),
969 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
970 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
971 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
972 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
973 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
974 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
975 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
976 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
977 "notify" => array("type" => "text"),
978 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
979 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
980 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
983 "PRIMARY" => array("id"),
984 "nurl" => array("UNIQUE", "nurl(190)"),
985 "name" => array("name(64)"),
986 "nick" => array("nick(32)"),
987 "addr" => array("addr(64)"),
988 "hide_network_updated" => array("hide", "network(4)", "updated"),
989 "updated" => array("updated"),
992 $database["glink"] = array(
994 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
995 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
996 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
997 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
998 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
999 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1002 "PRIMARY" => array("id"),
1003 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
1004 "gcid" => array("gcid"),
1007 $database["group"] = array(
1009 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1010 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1011 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1012 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1013 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1016 "PRIMARY" => array("id"),
1017 "uid" => array("uid"),
1020 $database["group_member"] = array(
1022 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1023 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1024 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1025 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1028 "PRIMARY" => array("id"),
1029 "contactid" => array("contact-id"),
1030 "gid_contactid" => array("gid", "contact-id"),
1031 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1034 $database["gserver"] = array(
1036 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1037 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1039 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1040 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "info" => array("type" => "text"),
1042 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1043 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1046 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1048 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1049 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1050 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1053 "PRIMARY" => array("id"),
1054 "nurl" => array("UNIQUE", "nurl(190)"),
1057 $database["hook"] = array(
1059 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1060 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1061 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1062 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1063 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1066 "PRIMARY" => array("id"),
1067 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1070 $database["intro"] = array(
1072 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1073 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1074 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1075 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1076 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1077 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1078 "note" => array("type" => "text"),
1079 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1080 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1081 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1082 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1085 "PRIMARY" => array("id"),
1088 $database["item"] = array(
1090 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1091 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1092 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1094 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1095 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1096 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1097 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1098 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1099 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1100 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1101 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1102 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1104 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1105 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1106 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1107 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1108 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1109 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1110 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1111 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1112 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1113 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1114 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1115 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "body" => array("type" => "mediumtext"),
1118 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1119 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1120 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1121 "object" => array("type" => "text"),
1122 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123 "target" => array("type" => "text"),
1124 "postopts" => array("type" => "text"),
1125 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1126 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1127 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1128 "tag" => array("type" => "mediumtext"),
1129 "attach" => array("type" => "mediumtext"),
1130 "inform" => array("type" => "mediumtext"),
1131 "file" => array("type" => "mediumtext"),
1132 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1133 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134 "allow_cid" => array("type" => "mediumtext"),
1135 "allow_gid" => array("type" => "mediumtext"),
1136 "deny_cid" => array("type" => "mediumtext"),
1137 "deny_gid" => array("type" => "mediumtext"),
1138 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1139 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1140 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1141 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1142 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1143 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1144 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1145 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1146 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1147 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1148 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1149 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1150 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1151 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1152 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1153 "rendered-html" => array("type" => "mediumtext"),
1154 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1157 "PRIMARY" => array("id"),
1158 "guid" => array("guid"),
1159 "uri" => array("uri"),
1160 "parent" => array("parent"),
1161 "parent-uri" => array("parent-uri"),
1162 "extid" => array("extid"),
1163 "uid_id" => array("uid","id"),
1164 "uid_contactid_id" => array("uid","contact-id","id"),
1165 "uid_created" => array("uid","created"),
1166 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1167 "uid_network_received" => array("uid","network(4)","received"),
1168 "uid_network_commented" => array("uid","network(4)","commented"),
1169 "uid_thrparent" => array("uid","thr-parent(190)"),
1170 "uid_parenturi" => array("uid","parent-uri(190)"),
1171 "uid_contactid_created" => array("uid","contact-id","created"),
1172 "authorid_created" => array("author-id","created"),
1173 "ownerid" => array("owner-id"),
1174 "uid_uri" => array("uid", "uri(190)"),
1175 "resource-id" => array("resource-id"),
1176 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1177 "uid_type_changed" => array("uid","type(190)","changed"),
1178 "contactid_verb" => array("contact-id","verb(190)"),
1179 "deleted_changed" => array("deleted","changed"),
1180 "uid_wall_changed" => array("uid","wall","changed"),
1181 "uid_eventid" => array("uid","event-id"),
1182 "uid_authorlink" => array("uid","author-link(190)"),
1183 "uid_ownerlink" => array("uid","owner-link(190)"),
1186 $database["item_id"] = array(
1188 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1189 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1190 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1191 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1192 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1195 "PRIMARY" => array("id"),
1196 "uid" => array("uid"),
1197 "sid" => array("sid"),
1198 "service" => array("service(32)"),
1199 "iid" => array("iid"),
1202 $database["locks"] = array(
1204 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1205 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1206 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1207 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1210 "PRIMARY" => array("id"),
1213 $database["mail"] = array(
1215 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1216 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1217 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1218 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1219 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1220 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1221 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1222 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1223 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1224 "body" => array("type" => "mediumtext"),
1225 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1226 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1227 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1228 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1229 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1230 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1231 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1234 "PRIMARY" => array("id"),
1235 "uid_seen" => array("uid", "seen"),
1236 "convid" => array("convid"),
1237 "uri" => array("uri(64)"),
1238 "parent-uri" => array("parent-uri(64)"),
1239 "contactid" => array("contact-id"),
1242 $database["mailacct"] = array(
1244 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1245 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1246 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1247 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1248 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1249 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1250 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1251 "pass" => array("type" => "text"),
1252 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1253 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1254 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1255 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1256 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1259 "PRIMARY" => array("id"),
1262 $database["manage"] = array(
1264 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1265 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1266 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1269 "PRIMARY" => array("id"),
1270 "uid_mid" => array("UNIQUE", "uid","mid"),
1273 $database["notify"] = array(
1275 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1276 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1277 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1278 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1279 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1280 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1281 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1282 "msg" => array("type" => "mediumtext"),
1283 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1284 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1285 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1286 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1287 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1288 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1289 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1290 "name_cache" => array("type" => "tinytext"),
1291 "msg_cache" => array("type" => "mediumtext")
1294 "PRIMARY" => array("id"),
1295 "hash_uid" => array("hash", "uid"),
1296 "seen_uid_date" => array("seen", "uid", "date"),
1297 "uid_date" => array("uid", "date"),
1298 "uid_type_link" => array("uid", "type", "link(190)"),
1301 $database["notify-threads"] = array(
1303 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1304 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1305 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1306 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1307 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1310 "PRIMARY" => array("id"),
1313 $database["oembed"] = array(
1315 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1316 "content" => array("type" => "mediumtext"),
1317 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1320 "PRIMARY" => array("url"),
1321 "created" => array("created"),
1324 $database["parsed_url"] = array(
1326 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1327 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1328 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1329 "content" => array("type" => "mediumtext"),
1330 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1333 "PRIMARY" => array("url", "guessing", "oembed"),
1334 "created" => array("created"),
1337 $database["pconfig"] = array(
1339 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1340 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1341 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1342 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1343 "v" => array("type" => "mediumtext"),
1346 "PRIMARY" => array("id"),
1347 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1350 $database["photo"] = array(
1352 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1353 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1354 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1355 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1356 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1357 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1358 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1359 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1360 "desc" => array("type" => "text"),
1361 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1362 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1363 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1364 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1365 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1366 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1367 "data" => array("type" => "mediumblob", "not null" => "1"),
1368 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1369 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1370 "allow_cid" => array("type" => "mediumtext"),
1371 "allow_gid" => array("type" => "mediumtext"),
1372 "deny_cid" => array("type" => "mediumtext"),
1373 "deny_gid" => array("type" => "mediumtext"),
1376 "PRIMARY" => array("id"),
1377 "contactid" => array("contact-id"),
1378 "uid_contactid" => array("uid", "contact-id"),
1379 "uid_profile" => array("uid", "profile"),
1380 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1381 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1382 "resource-id" => array("resource-id(64)"),
1385 $database["poll"] = array(
1387 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1388 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1389 "q0" => array("type" => "text"),
1390 "q1" => array("type" => "text"),
1391 "q2" => array("type" => "text"),
1392 "q3" => array("type" => "text"),
1393 "q4" => array("type" => "text"),
1394 "q5" => array("type" => "text"),
1395 "q6" => array("type" => "text"),
1396 "q7" => array("type" => "text"),
1397 "q8" => array("type" => "text"),
1398 "q9" => array("type" => "text"),
1401 "PRIMARY" => array("id"),
1402 "uid" => array("uid"),
1405 $database["poll_result"] = array(
1407 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1408 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1409 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1412 "PRIMARY" => array("id"),
1413 "poll_id" => array("poll_id"),
1414 "choice" => array("choice"),
1417 $database["process"] = array(
1419 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1420 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1421 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1424 "PRIMARY" => array("pid"),
1425 "command" => array("command"),
1428 $database["profile"] = array(
1430 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1431 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1432 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1433 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1434 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1435 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1436 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1437 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1438 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1439 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1440 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1441 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1442 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1443 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1444 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1445 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1446 "with" => array("type" => "text"),
1447 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1448 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1449 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1450 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1451 "pub_keywords" => array("type" => "text"),
1452 "prv_keywords" => array("type" => "text"),
1453 "likes" => array("type" => "text"),
1454 "dislikes" => array("type" => "text"),
1455 "about" => array("type" => "text"),
1456 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1457 "music" => array("type" => "text"),
1458 "book" => array("type" => "text"),
1459 "tv" => array("type" => "text"),
1460 "film" => array("type" => "text"),
1461 "interest" => array("type" => "text"),
1462 "romance" => array("type" => "text"),
1463 "work" => array("type" => "text"),
1464 "education" => array("type" => "text"),
1465 "contact" => array("type" => "text"),
1466 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1467 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1468 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1469 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1470 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1471 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1474 "PRIMARY" => array("id"),
1475 "uid_is-default" => array("uid", "is-default"),
1478 $database["profile_check"] = array(
1480 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1481 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1482 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1483 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1484 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1485 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1488 "PRIMARY" => array("id"),
1491 $database["push_subscriber"] = array(
1493 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1494 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1495 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1496 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1497 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1498 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1499 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1500 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1503 "PRIMARY" => array("id"),
1506 $database["queue"] = array(
1508 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1509 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1510 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1511 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1512 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1513 "content" => array("type" => "mediumtext"),
1514 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1517 "PRIMARY" => array("id"),
1518 "cid" => array("cid"),
1519 "created" => array("created"),
1520 "last" => array("last"),
1521 "network" => array("network"),
1522 "batch" => array("batch"),
1525 $database["register"] = array(
1527 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1528 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1529 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1530 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1531 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1532 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1533 "note" => array("type" => "text"),
1536 "PRIMARY" => array("id"),
1539 $database["search"] = array(
1541 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1542 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1543 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1546 "PRIMARY" => array("id"),
1547 "uid" => array("uid"),
1550 $database["session"] = array(
1552 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1553 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1554 "data" => array("type" => "text"),
1555 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1558 "PRIMARY" => array("id"),
1559 "sid" => array("sid(64)"),
1560 "expire" => array("expire"),
1563 $database["sign"] = array(
1565 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1566 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1567 "signed_text" => array("type" => "mediumtext"),
1568 "signature" => array("type" => "text"),
1569 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1572 "PRIMARY" => array("id"),
1573 "iid" => array("UNIQUE", "iid"),
1576 $database["spam"] = array(
1578 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1579 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1580 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1581 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1582 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1583 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1586 "PRIMARY" => array("id"),
1587 "uid" => array("uid"),
1588 "spam" => array("spam"),
1589 "ham" => array("ham"),
1590 "term" => array("term"),
1593 $database["term"] = array(
1595 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1596 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1597 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1598 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1599 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1600 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1601 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1602 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1603 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1604 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1605 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1606 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1609 "PRIMARY" => array("tid"),
1610 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1611 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1612 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1613 "guid" => array("guid(64)"),
1616 $database["thread"] = array(
1618 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1619 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1620 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1621 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1622 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1623 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1624 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1625 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1626 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1627 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1628 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1629 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1630 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1631 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1632 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1633 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1634 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1635 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1636 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1637 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1638 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1639 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1640 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1641 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1642 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1643 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1646 "PRIMARY" => array("iid"),
1647 "uid_network_commented" => array("uid","network","commented"),
1648 "uid_network_created" => array("uid","network","created"),
1649 "uid_contactid_commented" => array("uid","contact-id","commented"),
1650 "uid_contactid_created" => array("uid","contact-id","created"),
1651 "contactid" => array("contact-id"),
1652 "ownerid" => array("owner-id"),
1653 "authorid" => array("author-id"),
1654 "uid_created" => array("uid","created"),
1655 "uid_commented" => array("uid","commented"),
1656 "uid_wall_created" => array("uid","wall","created"),
1657 "private_wall_received" => array("private","wall","received"),
1660 $database["tokens"] = array(
1662 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1663 "secret" => array("type" => "text"),
1664 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1665 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1666 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1667 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1670 "PRIMARY" => array("id"),
1673 $database["user"] = array(
1675 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1676 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1677 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1678 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1679 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1680 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1681 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1682 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1683 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1684 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1685 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1686 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1687 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1688 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1689 "pubkey" => array("type" => "text"),
1690 "prvkey" => array("type" => "text"),
1691 "spubkey" => array("type" => "text"),
1692 "sprvkey" => array("type" => "text"),
1693 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1694 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1695 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1696 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1697 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1698 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1699 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1700 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1701 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1702 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1703 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1704 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1705 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1706 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1707 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1708 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1709 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1710 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1711 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1712 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1713 "allow_cid" => array("type" => "mediumtext"),
1714 "allow_gid" => array("type" => "mediumtext"),
1715 "deny_cid" => array("type" => "mediumtext"),
1716 "deny_gid" => array("type" => "mediumtext"),
1717 "openidserver" => array("type" => "text"),
1720 "PRIMARY" => array("uid"),
1721 "nickname" => array("nickname(32)"),
1724 $database["userd"] = array(
1726 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1727 "username" => array("type" => "varchar(255)", "not null" => "1"),
1730 "PRIMARY" => array("id"),
1731 "username" => array("username(32)"),
1734 $database["workerqueue"] = array(
1736 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1737 "parameter" => array("type" => "text"),
1738 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1739 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1740 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1741 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1742 "done" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1745 "PRIMARY" => array("id"),
1746 "pid" => array("pid"),
1747 "parameter" => array("parameter(64)"),
1748 "priority_created" => array("priority", "created"),
1749 "executed" => array("executed"),
1758 * run from command line
1760 function dbstructure_run(&$argv, &$argc) {
1764 $a = new App(dirname(__DIR__));
1767 @include ".htconfig.php";
1768 require_once "include/dba.php";
1769 dba::connect($db_host, $db_user, $db_pass, $db_data);
1770 unset($db_host, $db_user, $db_pass, $db_data);
1775 update_structure(true, false);
1778 update_structure(true, true);
1780 $build = get_config('system','build');
1782 set_config('system', 'build', DB_UPDATE_VERSION);
1783 $build = DB_UPDATE_VERSION;
1786 $stored = intval($build);
1787 $current = intval(DB_UPDATE_VERSION);
1789 // run any left update_nnnn functions in update.php
1790 for ($x = $stored; $x < $current; $x ++) {
1791 $r = run_update_function($x);
1797 set_config('system','build',DB_UPDATE_VERSION);
1800 print_structure(db_definition());
1803 convert_to_innodb();
1810 echo $argv[0]." <command>\n";
1813 echo "dryrun show database update schema queries without running them\n";
1814 echo "update update database schema\n";
1815 echo "dumpsql dump database schema\n";
1816 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1821 if (array_search(__FILE__,get_included_files())===0) {
1822 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);