3 use Friendica\Core\Config;
5 require_once("boot.php");
6 require_once("include/text.php");
8 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
11 * Converts all tables from MyISAM to InnoDB
13 function convert_to_innodb() {
16 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
17 dbesc($db->database_name()));
19 if (!dbm::is_result($r)) {
20 echo t('There are no tables on MyISAM.')."\n";
24 foreach ($r AS $table) {
25 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
28 $result = @$db->q($sql);
29 if (!dbm::is_result($result)) {
30 print_update_error($db, $sql);
36 * send the email and do what is needed to do on update fails
38 * @param update_id (int) number of failed update
39 * @param error_message (str) error message
41 function update_fail($update_id, $error_message) {
42 //send the administrators an e-mail
43 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
44 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
49 if (!dbm::is_result($adminlist)) {
50 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
56 // every admin could had different language
57 foreach ($adminlist as $admin) {
58 $lang = (($admin['language'])?$admin['language']:'en');
61 $preamble = deindent(t("
62 The friendica developers released update %s recently,
63 but when I tried to install it, something went terribly wrong.
64 This needs to be fixed soon and I can't do it alone. Please contact a
65 friendica developer if you can not help me on your own. My database might be invalid."));
66 $body = t("The error message is\n[pre]%s[/pre]");
67 $preamble = sprintf($preamble, $update_id);
68 $body = sprintf($body, $error_message);
71 'type' => "SYSTEM_EMAIL",
72 'to_email' => $admin['email'],
73 'preamble' => $preamble,
83 $email_tpl = get_intltext_template("update_fail_eml.tpl");
84 $email_msg = replace_macros($email_tpl, array(
85 '$sitename' => $a->config['sitename'],
86 '$siteurl' => App::get_baseurl(),
87 '$update' => DB_UPDATE_VERSION,
88 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
90 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
91 require_once('include/email.php');
92 $subject = email_header_encode($subject,'UTF-8');
93 mail($a->config['admin_email'], $subject, $email_msg,
94 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
95 .'Content-type: text/plain; charset=UTF-8'."\n"
96 .'Content-transfer-encoding: 8bit');
99 logger("CRITICAL: Database structure update failed: ".$retval);
103 function table_structure($table) {
104 $structures = q("DESCRIBE `%s`", $table);
106 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
108 $indexes = q("SHOW INDEX FROM `%s`", $table);
110 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
112 if (dbm::is_result($table_status)) {
113 $table_status = $table_status[0];
115 $table_status = array();
118 $fielddata = array();
119 $indexdata = array();
121 if (dbm::is_result($indexes))
122 foreach ($indexes AS $index) {
123 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
124 $indexdata[$index["Key_name"]] = array('UNIQUE');
127 $column = $index["Column_name"];
128 // On utf8mb4 a varchar index can only have a length of 191
129 // The "show index" command sometimes returns this value although this value wasn't added manually.
130 // Because we don't want to add this number to every index, we ignore bigger numbers
131 if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 191) OR ($index["Key_name"] == "PRIMARY"))) {
132 $column .= "(".$index["Sub_part"].")";
135 $indexdata[$index["Key_name"]][] = $column;
137 if (dbm::is_result($structures)) {
138 foreach ($structures AS $field) {
139 $fielddata[$field["Field"]]["type"] = $field["Type"];
140 if ($field["Null"] == "NO") {
141 $fielddata[$field["Field"]]["not null"] = true;
144 if (isset($field["Default"])) {
145 $fielddata[$field["Field"]]["default"] = $field["Default"];
148 if ($field["Extra"] != "") {
149 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
152 if ($field["Key"] == "PRI") {
153 $fielddata[$field["Field"]]["primary"] = true;
157 if (dbm::is_result($full_columns)) {
158 foreach ($full_columns AS $column) {
159 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
163 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
166 function print_structure($database) {
167 echo "-- ------------------------------------------\n";
168 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
169 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
170 echo "-- ------------------------------------------\n\n\n";
171 foreach ($database AS $name => $structure) {
173 echo "-- TABLE $name\n";
175 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
182 * @brief Print out database error messages
184 * @param object $db Database object
185 * @param string $message Message to be added to the error message
187 * @return string Error message
189 function print_update_error($db, $message) {
190 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
191 $db->errorno, $db->error);
193 return t('Errors encountered performing database changes: ').$message.EOL;
196 function update_structure($verbose, $action, $tables=null, $definition=null) {
200 Config::set('system', 'maintenance', 1);
201 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
206 logger('updating structure', LOGGER_DEBUG);
208 // Get the current structure
211 if (is_null($tables)) {
212 $tables = q("SHOW TABLES");
215 if (dbm::is_result($tables)) {
216 foreach ($tables AS $table) {
217 $table = current($table);
219 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
220 $database[$table] = table_structure($table);
224 // Get the definition
225 if (is_null($definition)) {
226 $definition = db_definition();
229 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
230 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
231 !(strpos($db->server_info(), 'MariaDB') !== false)) {
238 foreach ($definition AS $name => $structure) {
239 $is_new_table = False;
242 if (!isset($database[$name])) {
243 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
244 if (!dbm::is_result($r)) {
245 $errors .= print_update_error($db, $name);
247 $is_new_table = True;
252 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
253 if (isset($database[$name]["indexes"][$indexname])) {
254 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
256 $current_index_definition = "__NOT_SET__";
258 $new_index_definition = implode(",",$fieldnames);
259 if ($current_index_definition != $new_index_definition) {
260 if ($fieldnames[0] == "UNIQUE") {
263 $temp_name = "temp-".$name;
270 * Drop the index if it isn't present in the definition
271 * or the definition differ from current status
272 * and index name doesn't start with "local_"
274 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
275 $current_index_definition = implode(",",$fieldnames);
276 if (isset($structure["indexes"][$indexname])) {
277 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
279 $new_index_definition = "__NOT_SET__";
281 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
282 $sql2=db_drop_index($indexname);
284 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
290 // Compare the field structure field by field
291 foreach ($structure["fields"] AS $fieldname => $parameters) {
292 if (!isset($database[$name]["fields"][$fieldname])) {
293 $sql2=db_add_table_field($fieldname, $parameters);
295 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
300 // Compare the field definition
301 $field_definition = $database[$name]["fields"][$fieldname];
303 // Remove the relation data that is used for the referential integrity
304 unset($parameters['relation']);
306 // We change the collation after the indexes had been changed.
307 // This is done to avoid index length problems.
308 // So here we always ensure that there is no need to change it.
309 unset($parameters['Collation']);
310 unset($field_definition['Collation']);
312 $current_field_definition = implode(",", $field_definition);
313 $new_field_definition = implode(",", $parameters);
314 if ($current_field_definition != $new_field_definition) {
315 $sql2 = db_modify_table_field($fieldname, $parameters);
317 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
327 * Create the index if the index don't exists in database
328 * or the definition differ from the current status.
329 * Don't create keys if table is new
331 if (!$is_new_table) {
332 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
333 if (isset($database[$name]["indexes"][$indexname])) {
334 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
336 $current_index_definition = "__NOT_SET__";
338 $new_index_definition = implode(",",$fieldnames);
339 if ($current_index_definition != $new_index_definition) {
340 $sql2 = db_create_index($indexname, $fieldnames);
342 // Fetch the "group by" fields for unique indexes
343 if ($fieldnames[0] == "UNIQUE") {
344 $group_by = db_group_by($indexname, $fieldnames);
348 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
356 if (isset($database[$name]["table_status"]["Collation"])) {
357 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
358 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
361 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
372 // Now have a look at the field collations
373 // Compare the field structure field by field
374 foreach ($structure["fields"] AS $fieldname => $parameters) {
375 // Compare the field definition
376 $field_definition = $database[$name]["fields"][$fieldname];
378 // Define the default collation if not given
379 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
380 $parameters['Collation'] = 'utf8mb4_general_ci';
382 $parameters['Collation'] = null;
385 if ($field_definition['Collation'] != $parameters['Collation']) {
386 $sql2 = db_modify_table_field($fieldname, $parameters);
387 if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
388 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
397 if (substr($sql3, -2, 2) != "; ") {
402 // Ensure index conversion to unique removes duplicates
405 echo "SET session old_alter_table=1;\n";
407 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
415 echo "SET session old_alter_table=0;\n";
417 echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
418 echo "DROP TABLE `".$name."`;\n";
419 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
425 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
427 // Ensure index conversion to unique removes duplicates
430 $db->q("SET session old_alter_table=1;");
432 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
433 if (!dbm::is_result($r)) {
434 $errors .= print_update_error($db, $sql3);
441 if (!dbm::is_result($r)) {
442 $errors .= print_update_error($db, $sql3);
446 $db->q("SET session old_alter_table=0;");
448 $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
449 if (!dbm::is_result($r)) {
450 $errors .= print_update_error($db, $sql3);
453 $r = $db->q("DROP TABLE `".$name."`;");
454 if (!dbm::is_result($r)) {
455 $errors .= print_update_error($db, $sql3);
458 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
459 if (!dbm::is_result($r)) {
460 $errors .= print_update_error($db, $sql3);
470 Config::set('system', 'maintenance', 0);
471 Config::set('system', 'maintenance_reason', '');
477 function db_field_command($parameters, $create = true) {
478 $fieldstruct = $parameters["type"];
480 if (!is_null($parameters["Collation"])) {
481 $fieldstruct .= " COLLATE ".$parameters["Collation"];
484 if ($parameters["not null"])
485 $fieldstruct .= " NOT NULL";
487 if (isset($parameters["default"])) {
488 if (strpos(strtolower($parameters["type"]),"int")!==false) {
489 $fieldstruct .= " DEFAULT ".$parameters["default"];
491 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
494 if ($parameters["extra"] != "")
495 $fieldstruct .= " ".$parameters["extra"];
497 /*if (($parameters["primary"] != "") AND $create)
498 $fieldstruct .= " PRIMARY KEY";*/
500 return($fieldstruct);
503 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
511 $primary_keys = array();
512 foreach ($fields AS $fieldname => $field) {
513 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
514 if (x($field,'primary') and $field['primary']!='') {
515 $primary_keys[] = $fieldname;
519 if (!is_null($indexes)) {
520 foreach ($indexes AS $indexname => $fieldnames) {
521 $sql_index = db_create_index($indexname, $fieldnames, "");
522 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
526 $sql = implode(",\n\t", $sql_rows);
528 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
538 function db_add_table_field($fieldname, $parameters) {
539 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
543 function db_modify_table_field($fieldname, $parameters) {
544 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
548 function db_drop_index($indexname) {
549 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
553 function db_create_index($indexname, $fieldnames, $method="ADD") {
555 $method = strtoupper(trim($method));
556 if ($method!="" && $method!="ADD") {
557 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
561 if ($fieldnames[0] == "UNIQUE") {
562 array_shift($fieldnames);
563 $method .= ' UNIQUE';
567 foreach ($fieldnames AS $fieldname) {
571 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
572 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
574 $names .= "`".dbesc($fieldname)."`";
578 if ($indexname == "PRIMARY") {
579 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
583 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
587 function db_group_by($indexname, $fieldnames) {
589 if ($fieldnames[0] != "UNIQUE") {
593 array_shift($fieldnames);
596 foreach ($fieldnames AS $fieldname) {
600 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
601 $names .= "`".dbesc($matches[1])."`";
603 $names .= "`".dbesc($fieldname)."`";
607 $sql = sprintf(" GROUP BY %s", $names);
611 function db_definition() {
615 $database["addon"] = array(
617 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
618 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
619 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
620 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
621 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
622 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
623 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
626 "PRIMARY" => array("id"),
627 "name" => array("UNIQUE", "name"),
630 $database["attach"] = array(
632 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
633 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
634 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
635 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
636 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
637 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
638 "data" => array("type" => "longblob", "not null" => "1"),
639 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
640 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
641 "allow_cid" => array("type" => "mediumtext"),
642 "allow_gid" => array("type" => "mediumtext"),
643 "deny_cid" => array("type" => "mediumtext"),
644 "deny_gid" => array("type" => "mediumtext"),
647 "PRIMARY" => array("id"),
650 $database["auth_codes"] = array(
652 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
653 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
654 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
655 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
656 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
659 "PRIMARY" => array("id"),
662 $database["cache"] = array(
664 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
665 "v" => array("type" => "mediumtext"),
666 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
667 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
670 "PRIMARY" => array("k"),
671 "expire_mode_updated" => array("expire_mode", "updated"),
674 $database["challenge"] = array(
676 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
677 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
678 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
679 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
680 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
681 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
684 "PRIMARY" => array("id"),
687 $database["clients"] = array(
689 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
690 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
691 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
692 "name" => array("type" => "text"),
693 "icon" => array("type" => "text"),
694 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
697 "PRIMARY" => array("client_id"),
700 $database["config"] = array(
702 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
703 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
704 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
705 "v" => array("type" => "mediumtext"),
708 "PRIMARY" => array("id"),
709 "cat_k" => array("UNIQUE", "cat", "k"),
712 $database["contact"] = array(
714 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
715 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
716 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
717 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
718 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
719 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
720 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
721 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
722 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
723 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
724 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
725 "about" => array("type" => "text"),
726 "keywords" => array("type" => "text"),
727 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
728 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
729 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731 "photo" => array("type" => "text"),
732 "thumb" => array("type" => "text"),
733 "micro" => array("type" => "text"),
734 "site-pubkey" => array("type" => "text"),
735 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
741 "pubkey" => array("type" => "text"),
742 "prvkey" => array("type" => "text"),
743 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "request" => array("type" => "text"),
745 "notify" => array("type" => "text"),
746 "poll" => array("type" => "text"),
747 "confirm" => array("type" => "text"),
748 "poco" => array("type" => "text"),
749 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
750 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
751 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
752 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
753 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
755 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
756 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
757 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
758 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
759 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
760 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
761 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
762 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
763 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
764 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
765 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
766 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
767 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
768 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
769 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
770 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
772 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "reason" => array("type" => "text"),
774 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
775 "info" => array("type" => "mediumtext"),
776 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
777 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
778 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
779 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
780 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
781 "ffi_keyword_blacklist" => array("type" => "text"),
784 "PRIMARY" => array("id"),
785 "uid_name" => array("uid", "name(190)"),
786 "self_uid" => array("self", "uid"),
787 "alias_uid" => array("alias(32)", "uid"),
788 "pending_uid" => array("pending", "uid"),
789 "blocked_uid" => array("blocked", "uid"),
790 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
791 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
792 "addr_uid" => array("addr(32)", "uid"),
793 "nurl_uid" => array("nurl(32)", "uid"),
794 "nick_uid" => array("nick(32)", "uid"),
795 "dfrn-id" => array("dfrn-id"),
796 "issued-id" => array("issued-id"),
799 $database["conv"] = array(
801 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
802 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
803 "recips" => array("type" => "text"),
804 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
805 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
806 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
807 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
808 "subject" => array("type" => "text"),
811 "PRIMARY" => array("id"),
812 "uid" => array("uid"),
815 $database["conversation"] = array(
817 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
818 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
819 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
820 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
821 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
822 "source" => array("type" => "mediumtext"),
823 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
826 "PRIMARY" => array("item-uri"),
827 "conversation-uri" => array("conversation-uri"),
830 $database["event"] = array(
832 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
833 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
834 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
835 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
836 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
837 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
838 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
839 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
840 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
841 "summary" => array("type" => "text"),
842 "desc" => array("type" => "text"),
843 "location" => array("type" => "text"),
844 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
845 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
846 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
847 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
848 "allow_cid" => array("type" => "mediumtext"),
849 "allow_gid" => array("type" => "mediumtext"),
850 "deny_cid" => array("type" => "mediumtext"),
851 "deny_gid" => array("type" => "mediumtext"),
854 "PRIMARY" => array("id"),
855 "uid_start" => array("uid", "start"),
858 $database["fcontact"] = array(
860 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
861 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
862 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
863 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
864 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
865 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
866 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
867 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
868 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
869 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
872 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
873 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
874 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
875 "pubkey" => array("type" => "text"),
876 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
879 "PRIMARY" => array("id"),
880 "addr" => array("addr(32)"),
881 "url" => array("url"),
884 $database["ffinder"] = array(
886 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
887 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
888 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
889 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
892 "PRIMARY" => array("id"),
895 $database["fserver"] = array(
897 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
898 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
899 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "key" => array("type" => "text"),
903 "PRIMARY" => array("id"),
904 "server" => array("server(32)"),
907 $database["fsuggest"] = array(
909 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
910 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
911 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
912 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
913 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
914 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
915 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
916 "note" => array("type" => "text"),
917 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
920 "PRIMARY" => array("id"),
923 $database["gcign"] = array(
925 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
926 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
927 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
930 "PRIMARY" => array("id"),
931 "uid" => array("uid"),
932 "gcid" => array("gcid"),
935 $database["gcontact"] = array(
937 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
938 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
939 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
940 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
941 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
942 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
943 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
944 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
945 "updated" => array("type" => "datetime", "default" => NULL_DATE),
946 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
947 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
948 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
949 "about" => array("type" => "text"),
950 "keywords" => array("type" => "text"),
951 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
952 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
953 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
954 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
955 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
956 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
957 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "notify" => array("type" => "text"),
960 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
962 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
965 "PRIMARY" => array("id"),
966 "nurl" => array("nurl(64)"),
967 "name" => array("name(64)"),
968 "nick" => array("nick(32)"),
969 "addr" => array("addr(64)"),
970 "hide_network_updated" => array("hide", "network(4)", "updated"),
971 "updated" => array("updated"),
974 $database["glink"] = array(
976 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
977 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
978 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
979 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
980 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
981 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
984 "PRIMARY" => array("id"),
985 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
986 "gcid" => array("gcid"),
989 $database["group"] = array(
991 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
992 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
993 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
994 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
995 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
998 "PRIMARY" => array("id"),
999 "uid" => array("uid"),
1002 $database["group_member"] = array(
1004 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1005 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1006 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1007 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1010 "PRIMARY" => array("id"),
1011 "contactid" => array("contact-id"),
1012 "gid_contactid" => array("gid", "contact-id"),
1013 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1016 $database["gserver"] = array(
1018 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1019 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1020 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1021 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1022 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "info" => array("type" => "text"),
1024 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1025 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1026 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1027 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1028 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1029 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1030 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1031 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1032 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1035 "PRIMARY" => array("id"),
1036 "nurl" => array("nurl(32)"),
1039 $database["hook"] = array(
1041 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1042 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1048 "PRIMARY" => array("id"),
1049 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1052 $database["intro"] = array(
1054 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1055 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1056 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1057 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1058 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1059 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1060 "note" => array("type" => "text"),
1061 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1062 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1063 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1064 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1067 "PRIMARY" => array("id"),
1070 $database["item"] = array(
1072 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1073 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1074 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1075 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1076 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1077 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1078 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1079 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1080 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1081 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1082 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1083 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1084 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1085 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1086 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1087 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1088 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1089 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1090 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1091 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1092 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1095 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1096 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1097 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1098 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1099 "body" => array("type" => "mediumtext"),
1100 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1101 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1102 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "object" => array("type" => "text"),
1104 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "target" => array("type" => "text"),
1106 "postopts" => array("type" => "text"),
1107 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1108 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1109 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1110 "tag" => array("type" => "mediumtext"),
1111 "attach" => array("type" => "mediumtext"),
1112 "inform" => array("type" => "mediumtext"),
1113 "file" => array("type" => "mediumtext"),
1114 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1115 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "allow_cid" => array("type" => "mediumtext"),
1117 "allow_gid" => array("type" => "mediumtext"),
1118 "deny_cid" => array("type" => "mediumtext"),
1119 "deny_gid" => array("type" => "mediumtext"),
1120 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1121 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1122 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1123 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1124 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1125 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1126 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1127 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1128 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1129 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1130 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1131 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1132 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1133 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1134 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1135 "rendered-html" => array("type" => "mediumtext"),
1136 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1139 "PRIMARY" => array("id"),
1140 "guid" => array("guid"),
1141 "uri" => array("uri"),
1142 "parent" => array("parent"),
1143 "parent-uri" => array("parent-uri"),
1144 "extid" => array("extid"),
1145 "uid_id" => array("uid","id"),
1146 "uid_contactid_id" => array("uid","contact-id","id"),
1147 "uid_created" => array("uid","created"),
1148 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1149 "uid_network_received" => array("uid","network(4)","received"),
1150 "uid_network_commented" => array("uid","network(4)","commented"),
1151 "uid_thrparent" => array("uid","thr-parent(190)"),
1152 "uid_parenturi" => array("uid","parent-uri(190)"),
1153 "uid_contactid_created" => array("uid","contact-id","created"),
1154 "authorid_created" => array("author-id","created"),
1155 "ownerid" => array("owner-id"),
1156 "uid_uri" => array("uid", "uri(190)"),
1157 "resource-id" => array("resource-id"),
1158 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1159 "uid_type_changed" => array("uid","type(190)","changed"),
1160 "contactid_verb" => array("contact-id","verb(190)"),
1161 "deleted_changed" => array("deleted","changed"),
1162 "uid_wall_changed" => array("uid","wall","changed"),
1163 "uid_eventid" => array("uid","event-id"),
1164 "uid_authorlink" => array("uid","author-link(190)"),
1165 "uid_ownerlink" => array("uid","owner-link(190)"),
1168 $database["item_id"] = array(
1170 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1171 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1172 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1173 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1174 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1177 "PRIMARY" => array("id"),
1178 "uid" => array("uid"),
1179 "sid" => array("sid"),
1180 "service" => array("service(32)"),
1181 "iid" => array("iid"),
1184 $database["locks"] = array(
1186 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1187 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1188 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1189 "created" => array("type" => "datetime", "default" => NULL_DATE),
1192 "PRIMARY" => array("id"),
1195 $database["mail"] = array(
1197 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1198 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1199 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1200 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1201 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1202 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1203 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1204 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1205 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1206 "body" => array("type" => "mediumtext"),
1207 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1208 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1209 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1210 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1211 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1212 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1213 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1216 "PRIMARY" => array("id"),
1217 "uid_seen" => array("uid", "seen"),
1218 "convid" => array("convid"),
1219 "uri" => array("uri(64)"),
1220 "parent-uri" => array("parent-uri(64)"),
1223 $database["mailacct"] = array(
1225 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1226 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1227 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1228 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1229 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1230 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1231 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1232 "pass" => array("type" => "text"),
1233 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1234 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1235 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1236 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1237 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1240 "PRIMARY" => array("id"),
1243 $database["manage"] = array(
1245 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1246 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1247 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1250 "PRIMARY" => array("id"),
1251 "uid_mid" => array("UNIQUE", "uid","mid"),
1254 $database["notify"] = array(
1256 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1257 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1258 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1259 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1260 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1261 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1262 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1263 "msg" => array("type" => "mediumtext"),
1264 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1265 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1266 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1267 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1268 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1269 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1270 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1271 "name_cache" => array("type" => "tinytext"),
1272 "msg_cache" => array("type" => "mediumtext")
1275 "PRIMARY" => array("id"),
1276 "hash_uid" => array("hash", "uid"),
1277 "seen_uid_date" => array("seen", "uid", "date"),
1278 "uid_date" => array("uid", "date"),
1279 "uid_type_link" => array("uid", "type", "link(190)"),
1282 $database["notify-threads"] = array(
1284 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1285 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1286 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1287 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1288 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1291 "PRIMARY" => array("id"),
1294 $database["oembed"] = array(
1296 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1297 "content" => array("type" => "mediumtext"),
1298 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1301 "PRIMARY" => array("url"),
1302 "created" => array("created"),
1305 $database["parsed_url"] = array(
1307 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1308 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1309 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1310 "content" => array("type" => "mediumtext"),
1311 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1314 "PRIMARY" => array("url", "guessing", "oembed"),
1315 "created" => array("created"),
1318 $database["pconfig"] = array(
1320 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1321 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1322 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1323 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1324 "v" => array("type" => "mediumtext"),
1327 "PRIMARY" => array("id"),
1328 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1331 $database["photo"] = array(
1333 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1334 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1335 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1336 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1337 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1338 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1339 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1340 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1341 "desc" => array("type" => "text"),
1342 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1343 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1344 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1345 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1346 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1347 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1348 "data" => array("type" => "mediumblob", "not null" => "1"),
1349 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1350 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1351 "allow_cid" => array("type" => "mediumtext"),
1352 "allow_gid" => array("type" => "mediumtext"),
1353 "deny_cid" => array("type" => "mediumtext"),
1354 "deny_gid" => array("type" => "mediumtext"),
1357 "PRIMARY" => array("id"),
1358 "uid_contactid" => array("uid", "contact-id"),
1359 "uid_profile" => array("uid", "profile"),
1360 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1361 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1362 "resource-id" => array("resource-id(64)"),
1365 $database["poll"] = array(
1367 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1368 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1369 "q0" => array("type" => "text"),
1370 "q1" => array("type" => "text"),
1371 "q2" => array("type" => "text"),
1372 "q3" => array("type" => "text"),
1373 "q4" => array("type" => "text"),
1374 "q5" => array("type" => "text"),
1375 "q6" => array("type" => "text"),
1376 "q7" => array("type" => "text"),
1377 "q8" => array("type" => "text"),
1378 "q9" => array("type" => "text"),
1381 "PRIMARY" => array("id"),
1382 "uid" => array("uid"),
1385 $database["poll_result"] = array(
1387 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1388 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1389 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1392 "PRIMARY" => array("id"),
1393 "poll_id" => array("poll_id"),
1394 "choice" => array("choice"),
1397 $database["process"] = array(
1399 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1400 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1401 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1404 "PRIMARY" => array("pid"),
1405 "command" => array("command"),
1408 $database["profile"] = array(
1410 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1411 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1412 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1413 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1414 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1415 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1416 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1417 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1418 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1419 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1420 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1421 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1422 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1423 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1424 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1425 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1426 "with" => array("type" => "text"),
1427 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1428 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1429 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1430 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1431 "pub_keywords" => array("type" => "text"),
1432 "prv_keywords" => array("type" => "text"),
1433 "likes" => array("type" => "text"),
1434 "dislikes" => array("type" => "text"),
1435 "about" => array("type" => "text"),
1436 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1437 "music" => array("type" => "text"),
1438 "book" => array("type" => "text"),
1439 "tv" => array("type" => "text"),
1440 "film" => array("type" => "text"),
1441 "interest" => array("type" => "text"),
1442 "romance" => array("type" => "text"),
1443 "work" => array("type" => "text"),
1444 "education" => array("type" => "text"),
1445 "contact" => array("type" => "text"),
1446 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1447 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1448 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1449 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1450 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1451 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1454 "PRIMARY" => array("id"),
1455 "uid_is-default" => array("uid", "is-default"),
1458 $database["profile_check"] = array(
1460 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1461 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1462 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1463 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1464 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1465 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1468 "PRIMARY" => array("id"),
1471 $database["push_subscriber"] = array(
1473 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1474 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1475 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1476 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1477 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1478 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1479 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1480 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1483 "PRIMARY" => array("id"),
1486 $database["queue"] = array(
1488 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1489 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1490 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1491 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1492 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1493 "content" => array("type" => "mediumtext"),
1494 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1497 "PRIMARY" => array("id"),
1498 "cid" => array("cid"),
1499 "created" => array("created"),
1500 "last" => array("last"),
1501 "network" => array("network"),
1502 "batch" => array("batch"),
1505 $database["register"] = array(
1507 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1508 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1509 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1510 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1511 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1512 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1513 "note" => array("type" => "text"),
1516 "PRIMARY" => array("id"),
1519 $database["search"] = array(
1521 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1522 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1523 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1526 "PRIMARY" => array("id"),
1527 "uid" => array("uid"),
1530 $database["session"] = array(
1532 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1533 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1534 "data" => array("type" => "text"),
1535 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1538 "PRIMARY" => array("id"),
1539 "sid" => array("sid(64)"),
1540 "expire" => array("expire"),
1543 $database["sign"] = array(
1545 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1546 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1547 "signed_text" => array("type" => "mediumtext"),
1548 "signature" => array("type" => "text"),
1549 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1552 "PRIMARY" => array("id"),
1553 "iid" => array("iid"),
1556 $database["spam"] = array(
1558 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1559 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1560 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1561 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1562 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1563 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1566 "PRIMARY" => array("id"),
1567 "uid" => array("uid"),
1568 "spam" => array("spam"),
1569 "ham" => array("ham"),
1570 "term" => array("term"),
1573 $database["term"] = array(
1575 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1576 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1577 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1578 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1579 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1580 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1581 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1582 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1583 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1584 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1585 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1586 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1589 "PRIMARY" => array("tid"),
1590 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1591 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1592 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1593 "guid" => array("guid(64)"),
1596 $database["thread"] = array(
1598 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1599 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1600 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1601 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1602 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1603 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1604 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1605 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1606 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1607 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1608 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1609 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1610 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1611 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1612 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1613 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1614 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1615 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1616 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1617 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1618 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1619 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1620 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1621 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1622 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1623 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1626 "PRIMARY" => array("iid"),
1627 "uid_network_commented" => array("uid","network","commented"),
1628 "uid_network_created" => array("uid","network","created"),
1629 "uid_contactid_commented" => array("uid","contact-id","commented"),
1630 "uid_contactid_created" => array("uid","contact-id","created"),
1631 "contactid" => array("contact-id"),
1632 "ownerid" => array("owner-id"),
1633 "authorid" => array("author-id"),
1634 "uid_created" => array("uid","created"),
1635 "uid_commented" => array("uid","commented"),
1636 "uid_wall_created" => array("uid","wall","created"),
1639 $database["tokens"] = array(
1641 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1642 "secret" => array("type" => "text"),
1643 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1644 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1645 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1646 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1649 "PRIMARY" => array("id"),
1652 $database["user"] = array(
1654 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1655 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1656 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1657 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1658 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1659 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1660 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1661 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1662 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1663 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1664 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1665 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1666 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1667 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1668 "pubkey" => array("type" => "text"),
1669 "prvkey" => array("type" => "text"),
1670 "spubkey" => array("type" => "text"),
1671 "sprvkey" => array("type" => "text"),
1672 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1673 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1674 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1675 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1676 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1677 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1678 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1679 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1680 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1681 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1682 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1683 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1684 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1685 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1686 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1687 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1688 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1689 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1690 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1691 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1692 "allow_cid" => array("type" => "mediumtext"),
1693 "allow_gid" => array("type" => "mediumtext"),
1694 "deny_cid" => array("type" => "mediumtext"),
1695 "deny_gid" => array("type" => "mediumtext"),
1696 "openidserver" => array("type" => "text"),
1699 "PRIMARY" => array("uid"),
1700 "nickname" => array("nickname(32)"),
1703 $database["userd"] = array(
1705 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1706 "username" => array("type" => "varchar(255)", "not null" => "1"),
1709 "PRIMARY" => array("id"),
1710 "username" => array("username(32)"),
1713 $database["workerqueue"] = array(
1715 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1716 "parameter" => array("type" => "text"),
1717 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1718 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1719 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1720 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1723 "PRIMARY" => array("id"),
1732 * run from command line
1734 function dbstructure_run(&$argv, &$argc) {
1742 @include(".htconfig.php");
1743 require_once("include/dba.php");
1744 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1745 unset($db_host, $db_user, $db_pass, $db_data);
1751 update_structure(true, false);
1754 update_structure(true, true);
1756 $build = get_config('system','build');
1758 set_config('system','build',DB_UPDATE_VERSION);
1759 $build = DB_UPDATE_VERSION;
1762 $stored = intval($build);
1763 $current = intval(DB_UPDATE_VERSION);
1765 // run any left update_nnnn functions in update.php
1766 for ($x = $stored; $x < $current; $x ++) {
1767 $r = run_update_function($x);
1771 set_config('system','build',DB_UPDATE_VERSION);
1774 print_structure(db_definition());
1777 convert_to_innodb();
1784 echo $argv[0]." <command>\n";
1787 echo "dryrun show database update schema queries without running them\n";
1788 echo "update update database schema\n";
1789 echo "dumpsql dump database schema\n";
1790 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1795 if (array_search(__file__,get_included_files())===0) {
1796 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);