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 if ($is_unique && $ignore == '') {
403 foreach ($structure['fields'] AS $fieldname => $parameters) {
404 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
406 $field_list = rtrim($field_list, ',');
410 // Ensure index conversion to unique removes duplicates
413 echo "SET session old_alter_table=1;\n";
415 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
423 echo "SET session old_alter_table=0;\n";
425 echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
426 echo "DROP TABLE `".$name."`;\n";
427 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
433 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
435 // Ensure index conversion to unique removes duplicates
438 $db->q("SET session old_alter_table=1;");
440 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
441 if (!dbm::is_result($r)) {
442 $errors .= print_update_error($db, $sql3);
449 if (!dbm::is_result($r)) {
450 $errors .= print_update_error($db, $sql3);
454 $db->q("SET session old_alter_table=0;");
456 $r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
457 if (!dbm::is_result($r)) {
458 $errors .= print_update_error($db, $sql3);
461 $r = $db->q("DROP TABLE `".$name."`;");
462 if (!dbm::is_result($r)) {
463 $errors .= print_update_error($db, $sql3);
466 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
467 if (!dbm::is_result($r)) {
468 $errors .= print_update_error($db, $sql3);
478 Config::set('system', 'maintenance', 0);
479 Config::set('system', 'maintenance_reason', '');
485 function db_field_command($parameters, $create = true) {
486 $fieldstruct = $parameters["type"];
488 if (!is_null($parameters["Collation"])) {
489 $fieldstruct .= " COLLATE ".$parameters["Collation"];
492 if ($parameters["not null"])
493 $fieldstruct .= " NOT NULL";
495 if (isset($parameters["default"])) {
496 if (strpos(strtolower($parameters["type"]),"int")!==false) {
497 $fieldstruct .= " DEFAULT ".$parameters["default"];
499 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
502 if ($parameters["extra"] != "")
503 $fieldstruct .= " ".$parameters["extra"];
505 /*if (($parameters["primary"] != "") AND $create)
506 $fieldstruct .= " PRIMARY KEY";*/
508 return($fieldstruct);
511 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
519 $primary_keys = array();
520 foreach ($fields AS $fieldname => $field) {
521 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
522 if (x($field,'primary') and $field['primary']!='') {
523 $primary_keys[] = $fieldname;
527 if (!is_null($indexes)) {
528 foreach ($indexes AS $indexname => $fieldnames) {
529 $sql_index = db_create_index($indexname, $fieldnames, "");
530 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
534 $sql = implode(",\n\t", $sql_rows);
536 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
546 function db_add_table_field($fieldname, $parameters) {
547 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
551 function db_modify_table_field($fieldname, $parameters) {
552 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
556 function db_drop_index($indexname) {
557 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
561 function db_create_index($indexname, $fieldnames, $method="ADD") {
563 $method = strtoupper(trim($method));
564 if ($method!="" && $method!="ADD") {
565 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
569 if ($fieldnames[0] == "UNIQUE") {
570 array_shift($fieldnames);
571 $method .= ' UNIQUE';
575 foreach ($fieldnames AS $fieldname) {
579 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
580 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
582 $names .= "`".dbesc($fieldname)."`";
586 if ($indexname == "PRIMARY") {
587 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
591 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
595 function db_group_by($indexname, $fieldnames) {
597 if ($fieldnames[0] != "UNIQUE") {
601 array_shift($fieldnames);
604 foreach ($fieldnames AS $fieldname) {
608 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
609 $names .= "`".dbesc($matches[1])."`";
611 $names .= "`".dbesc($fieldname)."`";
615 $sql = sprintf(" GROUP BY %s", $names);
619 function db_definition() {
623 $database["addon"] = array(
625 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
626 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
627 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
628 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
629 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
630 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
631 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
634 "PRIMARY" => array("id"),
635 "name" => array("UNIQUE", "name"),
638 $database["attach"] = array(
640 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
641 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
642 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
643 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
644 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
645 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
646 "data" => array("type" => "longblob", "not null" => "1"),
647 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
648 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
649 "allow_cid" => array("type" => "mediumtext"),
650 "allow_gid" => array("type" => "mediumtext"),
651 "deny_cid" => array("type" => "mediumtext"),
652 "deny_gid" => array("type" => "mediumtext"),
655 "PRIMARY" => array("id"),
658 $database["auth_codes"] = array(
660 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
661 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
662 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
663 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
664 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
667 "PRIMARY" => array("id"),
670 $database["cache"] = array(
672 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
673 "v" => array("type" => "mediumtext"),
674 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
675 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
678 "PRIMARY" => array("k"),
679 "expire_mode_updated" => array("expire_mode", "updated"),
682 $database["challenge"] = array(
684 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
685 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
686 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
687 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
688 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
689 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
692 "PRIMARY" => array("id"),
695 $database["clients"] = array(
697 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
698 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
699 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
700 "name" => array("type" => "text"),
701 "icon" => array("type" => "text"),
702 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
705 "PRIMARY" => array("client_id"),
708 $database["config"] = array(
710 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
711 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
712 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
713 "v" => array("type" => "mediumtext"),
716 "PRIMARY" => array("id"),
717 "cat_k" => array("UNIQUE", "cat", "k"),
720 $database["contact"] = array(
722 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
723 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
724 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
725 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
726 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
727 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
728 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
729 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "about" => array("type" => "text"),
734 "keywords" => array("type" => "text"),
735 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
736 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "photo" => array("type" => "text"),
740 "thumb" => array("type" => "text"),
741 "micro" => array("type" => "text"),
742 "site-pubkey" => array("type" => "text"),
743 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "pubkey" => array("type" => "text"),
750 "prvkey" => array("type" => "text"),
751 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "request" => array("type" => "text"),
753 "notify" => array("type" => "text"),
754 "poll" => array("type" => "text"),
755 "confirm" => array("type" => "text"),
756 "poco" => array("type" => "text"),
757 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
758 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
759 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
760 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
761 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
762 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
763 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
764 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
765 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
766 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
767 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
768 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
769 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
770 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
771 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
772 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
775 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
776 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
777 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
778 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
779 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
780 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
781 "reason" => array("type" => "text"),
782 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
783 "info" => array("type" => "mediumtext"),
784 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
785 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
786 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
787 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "ffi_keyword_blacklist" => array("type" => "text"),
792 "PRIMARY" => array("id"),
793 "uid_name" => array("uid", "name(190)"),
794 "self_uid" => array("self", "uid"),
795 "alias_uid" => array("alias(32)", "uid"),
796 "pending_uid" => array("pending", "uid"),
797 "blocked_uid" => array("blocked", "uid"),
798 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
799 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
800 "addr_uid" => array("addr(32)", "uid"),
801 "nurl_uid" => array("nurl(32)", "uid"),
802 "nick_uid" => array("nick(32)", "uid"),
803 "dfrn-id" => array("dfrn-id"),
804 "issued-id" => array("issued-id"),
807 $database["conv"] = array(
809 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
810 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
811 "recips" => array("type" => "text"),
812 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
813 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
814 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
815 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
816 "subject" => array("type" => "text"),
819 "PRIMARY" => array("id"),
820 "uid" => array("uid"),
823 $database["conversation"] = array(
825 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
826 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
827 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
828 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
829 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
830 "source" => array("type" => "mediumtext"),
831 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
834 "PRIMARY" => array("item-uri"),
835 "conversation-uri" => array("conversation-uri"),
838 $database["event"] = array(
840 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
841 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
842 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
843 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
844 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
845 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
846 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
847 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
848 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
849 "summary" => array("type" => "text"),
850 "desc" => array("type" => "text"),
851 "location" => array("type" => "text"),
852 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
853 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
854 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
855 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
856 "allow_cid" => array("type" => "mediumtext"),
857 "allow_gid" => array("type" => "mediumtext"),
858 "deny_cid" => array("type" => "mediumtext"),
859 "deny_gid" => array("type" => "mediumtext"),
862 "PRIMARY" => array("id"),
863 "uid_start" => array("uid", "start"),
866 $database["fcontact"] = array(
868 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
869 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
872 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
873 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
875 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
877 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
878 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
879 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
880 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
881 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
882 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
883 "pubkey" => array("type" => "text"),
884 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
887 "PRIMARY" => array("id"),
888 "addr" => array("addr(32)"),
889 "url" => array("UNIQUE", "url(190)"),
892 $database["ffinder"] = array(
894 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
895 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
896 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
897 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
900 "PRIMARY" => array("id"),
903 $database["fserver"] = array(
905 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
906 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
907 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
908 "key" => array("type" => "text"),
911 "PRIMARY" => array("id"),
912 "server" => array("server(32)"),
915 $database["fsuggest"] = array(
917 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
918 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
919 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
920 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
921 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
922 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
923 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
924 "note" => array("type" => "text"),
925 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
928 "PRIMARY" => array("id"),
931 $database["gcign"] = array(
933 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
934 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
935 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
938 "PRIMARY" => array("id"),
939 "uid" => array("uid"),
940 "gcid" => array("gcid"),
943 $database["gcontact"] = array(
945 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
946 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
947 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
948 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
949 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
950 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
951 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
952 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
953 "updated" => array("type" => "datetime", "default" => NULL_DATE),
954 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
955 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
956 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
957 "about" => array("type" => "text"),
958 "keywords" => array("type" => "text"),
959 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
960 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
961 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
962 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
963 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
964 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
965 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
966 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
967 "notify" => array("type" => "text"),
968 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
969 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
970 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
973 "PRIMARY" => array("id"),
974 "nurl" => array("UNIQUE", "nurl(190)"),
975 "name" => array("name(64)"),
976 "nick" => array("nick(32)"),
977 "addr" => array("addr(64)"),
978 "hide_network_updated" => array("hide", "network(4)", "updated"),
979 "updated" => array("updated"),
982 $database["glink"] = array(
984 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
985 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
986 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
987 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
988 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
989 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
992 "PRIMARY" => array("id"),
993 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
994 "gcid" => array("gcid"),
997 $database["group"] = array(
999 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1000 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1001 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1002 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1003 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1006 "PRIMARY" => array("id"),
1007 "uid" => array("uid"),
1010 $database["group_member"] = array(
1012 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1013 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1014 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1015 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1018 "PRIMARY" => array("id"),
1019 "contactid" => array("contact-id"),
1020 "gid_contactid" => array("gid", "contact-id"),
1021 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1024 $database["gserver"] = array(
1026 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1027 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1028 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1029 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1030 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1031 "info" => array("type" => "text"),
1032 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1033 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1034 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1036 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1037 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1038 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1039 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1040 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1043 "PRIMARY" => array("id"),
1044 "nurl" => array("UNIQUE", "nurl(190)"),
1047 $database["hook"] = array(
1049 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1050 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1051 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1052 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1053 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1056 "PRIMARY" => array("id"),
1057 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1060 $database["intro"] = array(
1062 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1063 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1064 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1065 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1066 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1067 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1068 "note" => array("type" => "text"),
1069 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1070 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1071 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1072 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1075 "PRIMARY" => array("id"),
1078 $database["item"] = array(
1080 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1081 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1082 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1083 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1084 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1085 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1086 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1087 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1088 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1089 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1090 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1091 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1092 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1094 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1095 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1096 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1097 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1098 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1099 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1100 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1101 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1102 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1103 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1107 "body" => array("type" => "mediumtext"),
1108 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1109 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1110 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1111 "object" => array("type" => "text"),
1112 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1113 "target" => array("type" => "text"),
1114 "postopts" => array("type" => "text"),
1115 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1118 "tag" => array("type" => "mediumtext"),
1119 "attach" => array("type" => "mediumtext"),
1120 "inform" => array("type" => "mediumtext"),
1121 "file" => array("type" => "mediumtext"),
1122 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1124 "allow_cid" => array("type" => "mediumtext"),
1125 "allow_gid" => array("type" => "mediumtext"),
1126 "deny_cid" => array("type" => "mediumtext"),
1127 "deny_gid" => array("type" => "mediumtext"),
1128 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1129 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1130 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1131 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1132 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1133 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1134 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1135 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1136 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1137 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1138 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1139 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1140 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1141 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1142 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1143 "rendered-html" => array("type" => "mediumtext"),
1144 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1147 "PRIMARY" => array("id"),
1148 "guid" => array("guid"),
1149 "uri" => array("uri"),
1150 "parent" => array("parent"),
1151 "parent-uri" => array("parent-uri"),
1152 "extid" => array("extid"),
1153 "uid_id" => array("uid","id"),
1154 "uid_contactid_id" => array("uid","contact-id","id"),
1155 "uid_created" => array("uid","created"),
1156 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1157 "uid_network_received" => array("uid","network(4)","received"),
1158 "uid_network_commented" => array("uid","network(4)","commented"),
1159 "uid_thrparent" => array("uid","thr-parent(190)"),
1160 "uid_parenturi" => array("uid","parent-uri(190)"),
1161 "uid_contactid_created" => array("uid","contact-id","created"),
1162 "authorid_created" => array("author-id","created"),
1163 "ownerid" => array("owner-id"),
1164 "uid_uri" => array("uid", "uri(190)"),
1165 "resource-id" => array("resource-id"),
1166 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1167 "uid_type_changed" => array("uid","type(190)","changed"),
1168 "contactid_verb" => array("contact-id","verb(190)"),
1169 "deleted_changed" => array("deleted","changed"),
1170 "uid_wall_changed" => array("uid","wall","changed"),
1171 "uid_eventid" => array("uid","event-id"),
1172 "uid_authorlink" => array("uid","author-link(190)"),
1173 "uid_ownerlink" => array("uid","owner-link(190)"),
1176 $database["item_id"] = array(
1178 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1179 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1180 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1181 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1182 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1185 "PRIMARY" => array("id"),
1186 "uid" => array("uid"),
1187 "sid" => array("sid"),
1188 "service" => array("service(32)"),
1189 "iid" => array("iid"),
1192 $database["locks"] = array(
1194 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1195 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1196 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1197 "created" => array("type" => "datetime", "default" => NULL_DATE),
1200 "PRIMARY" => array("id"),
1203 $database["mail"] = array(
1205 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1206 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1207 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1208 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1209 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1210 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1211 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1212 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1213 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1214 "body" => array("type" => "mediumtext"),
1215 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1216 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1217 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1218 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1219 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1220 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1221 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1224 "PRIMARY" => array("id"),
1225 "uid_seen" => array("uid", "seen"),
1226 "convid" => array("convid"),
1227 "uri" => array("uri(64)"),
1228 "parent-uri" => array("parent-uri(64)"),
1229 "contactid" => array("contact-id"),
1232 $database["mailacct"] = array(
1234 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1235 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1236 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1237 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1238 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1239 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1240 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1241 "pass" => array("type" => "text"),
1242 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1243 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1244 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1245 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1246 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1249 "PRIMARY" => array("id"),
1252 $database["manage"] = array(
1254 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1255 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1256 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1259 "PRIMARY" => array("id"),
1260 "uid_mid" => array("UNIQUE", "uid","mid"),
1263 $database["notify"] = array(
1265 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1266 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1267 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1268 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1269 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1270 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1271 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1272 "msg" => array("type" => "mediumtext"),
1273 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1274 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1275 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1276 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1277 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1278 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1279 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1280 "name_cache" => array("type" => "tinytext"),
1281 "msg_cache" => array("type" => "mediumtext")
1284 "PRIMARY" => array("id"),
1285 "hash_uid" => array("hash", "uid"),
1286 "seen_uid_date" => array("seen", "uid", "date"),
1287 "uid_date" => array("uid", "date"),
1288 "uid_type_link" => array("uid", "type", "link(190)"),
1291 $database["notify-threads"] = array(
1293 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1294 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1295 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1296 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1297 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1300 "PRIMARY" => array("id"),
1303 $database["oembed"] = array(
1305 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1306 "content" => array("type" => "mediumtext"),
1307 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1310 "PRIMARY" => array("url"),
1311 "created" => array("created"),
1314 $database["parsed_url"] = array(
1316 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1317 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1318 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1319 "content" => array("type" => "mediumtext"),
1320 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1323 "PRIMARY" => array("url", "guessing", "oembed"),
1324 "created" => array("created"),
1327 $database["pconfig"] = array(
1329 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1330 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1331 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1332 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1333 "v" => array("type" => "mediumtext"),
1336 "PRIMARY" => array("id"),
1337 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1340 $database["photo"] = array(
1342 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1343 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1344 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1345 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1346 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1347 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1348 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1349 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1350 "desc" => array("type" => "text"),
1351 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1352 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1353 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1354 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1355 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1356 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1357 "data" => array("type" => "mediumblob", "not null" => "1"),
1358 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1359 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1360 "allow_cid" => array("type" => "mediumtext"),
1361 "allow_gid" => array("type" => "mediumtext"),
1362 "deny_cid" => array("type" => "mediumtext"),
1363 "deny_gid" => array("type" => "mediumtext"),
1366 "PRIMARY" => array("id"),
1367 "contactid" => array("contact-id"),
1368 "uid_contactid" => array("uid", "contact-id"),
1369 "uid_profile" => array("uid", "profile"),
1370 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1371 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1372 "resource-id" => array("resource-id(64)"),
1375 $database["poll"] = array(
1377 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1378 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1379 "q0" => array("type" => "text"),
1380 "q1" => array("type" => "text"),
1381 "q2" => array("type" => "text"),
1382 "q3" => array("type" => "text"),
1383 "q4" => array("type" => "text"),
1384 "q5" => array("type" => "text"),
1385 "q6" => array("type" => "text"),
1386 "q7" => array("type" => "text"),
1387 "q8" => array("type" => "text"),
1388 "q9" => array("type" => "text"),
1391 "PRIMARY" => array("id"),
1392 "uid" => array("uid"),
1395 $database["poll_result"] = array(
1397 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1398 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1399 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1402 "PRIMARY" => array("id"),
1403 "poll_id" => array("poll_id"),
1404 "choice" => array("choice"),
1407 $database["process"] = array(
1409 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1410 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1411 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1414 "PRIMARY" => array("pid"),
1415 "command" => array("command"),
1418 $database["profile"] = array(
1420 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1421 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1422 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1423 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1424 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1425 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1426 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1427 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1428 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1429 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1430 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1431 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1432 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1433 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1434 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1435 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1436 "with" => array("type" => "text"),
1437 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1438 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1439 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1440 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1441 "pub_keywords" => array("type" => "text"),
1442 "prv_keywords" => array("type" => "text"),
1443 "likes" => array("type" => "text"),
1444 "dislikes" => array("type" => "text"),
1445 "about" => array("type" => "text"),
1446 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1447 "music" => array("type" => "text"),
1448 "book" => array("type" => "text"),
1449 "tv" => array("type" => "text"),
1450 "film" => array("type" => "text"),
1451 "interest" => array("type" => "text"),
1452 "romance" => array("type" => "text"),
1453 "work" => array("type" => "text"),
1454 "education" => array("type" => "text"),
1455 "contact" => array("type" => "text"),
1456 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1457 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1458 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1459 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1460 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1461 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1464 "PRIMARY" => array("id"),
1465 "uid_is-default" => array("uid", "is-default"),
1468 $database["profile_check"] = array(
1470 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1471 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1472 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1473 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1474 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1475 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1478 "PRIMARY" => array("id"),
1481 $database["push_subscriber"] = array(
1483 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1484 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1485 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1486 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1487 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1488 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1489 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1490 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1493 "PRIMARY" => array("id"),
1496 $database["queue"] = array(
1498 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1499 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1500 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1501 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1502 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1503 "content" => array("type" => "mediumtext"),
1504 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1507 "PRIMARY" => array("id"),
1508 "cid" => array("cid"),
1509 "created" => array("created"),
1510 "last" => array("last"),
1511 "network" => array("network"),
1512 "batch" => array("batch"),
1515 $database["register"] = array(
1517 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1518 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1519 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1520 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1521 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1522 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1523 "note" => array("type" => "text"),
1526 "PRIMARY" => array("id"),
1529 $database["search"] = array(
1531 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1532 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1533 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1536 "PRIMARY" => array("id"),
1537 "uid" => array("uid"),
1540 $database["session"] = array(
1542 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1543 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1544 "data" => array("type" => "text"),
1545 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1548 "PRIMARY" => array("id"),
1549 "sid" => array("sid(64)"),
1550 "expire" => array("expire"),
1553 $database["sign"] = array(
1555 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1556 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1557 "signed_text" => array("type" => "mediumtext"),
1558 "signature" => array("type" => "text"),
1559 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1562 "PRIMARY" => array("id"),
1563 "iid" => array("iid"),
1566 $database["spam"] = array(
1568 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1569 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1570 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1571 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1572 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1573 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1576 "PRIMARY" => array("id"),
1577 "uid" => array("uid"),
1578 "spam" => array("spam"),
1579 "ham" => array("ham"),
1580 "term" => array("term"),
1583 $database["term"] = array(
1585 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1586 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1587 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1588 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1589 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1590 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1591 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1592 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1593 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1594 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1595 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1596 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1599 "PRIMARY" => array("tid"),
1600 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1601 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1602 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1603 "guid" => array("guid(64)"),
1606 $database["thread"] = array(
1608 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1609 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1610 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1611 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1612 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1613 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1614 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1615 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1616 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1617 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1618 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1619 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1620 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1621 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1622 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1623 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1624 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1625 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1626 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1627 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1628 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1629 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1630 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1631 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1632 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1633 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1636 "PRIMARY" => array("iid"),
1637 "uid_network_commented" => array("uid","network","commented"),
1638 "uid_network_created" => array("uid","network","created"),
1639 "uid_contactid_commented" => array("uid","contact-id","commented"),
1640 "uid_contactid_created" => array("uid","contact-id","created"),
1641 "contactid" => array("contact-id"),
1642 "ownerid" => array("owner-id"),
1643 "authorid" => array("author-id"),
1644 "uid_created" => array("uid","created"),
1645 "uid_commented" => array("uid","commented"),
1646 "uid_wall_created" => array("uid","wall","created"),
1649 $database["tokens"] = array(
1651 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1652 "secret" => array("type" => "text"),
1653 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1654 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1655 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1656 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1659 "PRIMARY" => array("id"),
1662 $database["user"] = array(
1664 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1665 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1666 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1667 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1668 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1669 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1670 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1671 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1672 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1673 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1674 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1675 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1676 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1677 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1678 "pubkey" => array("type" => "text"),
1679 "prvkey" => array("type" => "text"),
1680 "spubkey" => array("type" => "text"),
1681 "sprvkey" => array("type" => "text"),
1682 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1683 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1684 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1685 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1686 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1687 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1688 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1689 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1690 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1691 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1692 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1693 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1694 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1695 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1696 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1697 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1698 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1699 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1700 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1701 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1702 "allow_cid" => array("type" => "mediumtext"),
1703 "allow_gid" => array("type" => "mediumtext"),
1704 "deny_cid" => array("type" => "mediumtext"),
1705 "deny_gid" => array("type" => "mediumtext"),
1706 "openidserver" => array("type" => "text"),
1709 "PRIMARY" => array("uid"),
1710 "nickname" => array("nickname(32)"),
1713 $database["userd"] = array(
1715 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1716 "username" => array("type" => "varchar(255)", "not null" => "1"),
1719 "PRIMARY" => array("id"),
1720 "username" => array("username(32)"),
1723 $database["workerqueue"] = array(
1725 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1726 "parameter" => array("type" => "text"),
1727 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1728 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1729 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1730 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1733 "PRIMARY" => array("id"),
1742 * run from command line
1744 function dbstructure_run(&$argv, &$argc) {
1752 @include(".htconfig.php");
1753 require_once("include/dba.php");
1754 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1755 unset($db_host, $db_user, $db_pass, $db_data);
1761 update_structure(true, false);
1764 update_structure(true, true);
1766 $build = get_config('system','build');
1768 set_config('system','build',DB_UPDATE_VERSION);
1769 $build = DB_UPDATE_VERSION;
1772 $stored = intval($build);
1773 $current = intval(DB_UPDATE_VERSION);
1775 // run any left update_nnnn functions in update.php
1776 for ($x = $stored; $x < $current; $x ++) {
1777 $r = run_update_function($x);
1781 set_config('system','build',DB_UPDATE_VERSION);
1784 print_structure(db_definition());
1787 convert_to_innodb();
1794 echo $argv[0]." <command>\n";
1797 echo "dryrun show database update schema queries without running them\n";
1798 echo "update update database schema\n";
1799 echo "dumpsql dump database schema\n";
1800 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1805 if (array_search(__file__,get_included_files())===0) {
1806 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);