4 use Friendica\Core\System;
5 use Friendica\Core\Config;
7 require_once "boot.php";
8 require_once "include/text.php";
10 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
12 const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before
13 const DB_UPDATE_SUCCESSFUL = 1; // Database check was successful
14 const DB_UPDATE_FAILED = 2; // Database check failed
17 * Converts all tables from MyISAM to InnoDB
19 function convert_to_innodb() {
20 $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
21 dbesc(dba::database_name()));
23 if (!dbm::is_result($r)) {
24 echo t('There are no tables on MyISAM.')."\n";
28 foreach ($r AS $table) {
29 $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
32 $result = dba::e($sql);
33 if (!dbm::is_result($result)) {
34 print_update_error($sql);
40 * send the email and do what is needed to do on update fails
42 * @param update_id (int) number of failed update
43 * @param error_message (str) error message
45 function update_fail($update_id, $error_message) {
46 //send the administrators an e-mail
47 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
48 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
53 if (!dbm::is_result($adminlist)) {
54 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
60 // every admin could had different language
61 foreach ($adminlist as $admin) {
62 $lang = (($admin['language'])?$admin['language']:'en');
65 $preamble = deindent(t("
66 The friendica developers released update %s recently,
67 but when I tried to install it, something went terribly wrong.
68 This needs to be fixed soon and I can't do it alone. Please contact a
69 friendica developer if you can not help me on your own. My database might be invalid."));
70 $body = t("The error message is\n[pre]%s[/pre]");
71 $preamble = sprintf($preamble, $update_id);
72 $body = sprintf($body, $error_message);
75 'type' => SYSTEM_EMAIL,
76 'to_email' => $admin['email'],
77 'preamble' => $preamble,
87 @TODO deprecated code?
88 $email_tpl = get_intltext_template("update_fail_eml.tpl");
89 $email_msg = replace_macros($email_tpl, array(
90 '$sitename' => $a->config['sitename'],
91 '$siteurl' => System::baseUrl(),
92 '$update' => DB_UPDATE_VERSION,
93 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
95 $subject=sprintf(t('Update Error at %s'), System::baseUrl());
96 require_once('include/email.php');
97 $subject = email_header_encode($subject,'UTF-8');
98 mail($a->config['admin_email'], $subject, $email_msg,
99 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
100 .'Content-type: text/plain; charset=UTF-8'."\n"
101 .'Content-transfer-encoding: 8bit');
104 logger("CRITICAL: Database structure update failed: ".$retval);
108 function table_structure($table) {
109 $structures = q("DESCRIBE `%s`", $table);
111 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
113 $indexes = q("SHOW INDEX FROM `%s`", $table);
115 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
117 if (dbm::is_result($table_status)) {
118 $table_status = $table_status[0];
120 $table_status = array();
123 $fielddata = array();
124 $indexdata = array();
126 if (dbm::is_result($indexes))
127 foreach ($indexes AS $index) {
128 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
129 $indexdata[$index["Key_name"]] = array('UNIQUE');
132 $column = $index["Column_name"];
133 // On utf8mb4 a varchar index can only have a length of 191
134 // The "show index" command sometimes returns this value although this value wasn't added manually.
135 // Because we don't want to add this number to every index, we ignore bigger numbers
136 if (($index["Sub_part"] != "") && (($index["Sub_part"] < 191) || ($index["Key_name"] == "PRIMARY"))) {
137 $column .= "(".$index["Sub_part"].")";
140 $indexdata[$index["Key_name"]][] = $column;
142 if (dbm::is_result($structures)) {
143 foreach ($structures AS $field) {
144 $fielddata[$field["Field"]]["type"] = $field["Type"];
145 if ($field["Null"] == "NO") {
146 $fielddata[$field["Field"]]["not null"] = true;
149 if (isset($field["Default"])) {
150 $fielddata[$field["Field"]]["default"] = $field["Default"];
153 if ($field["Extra"] != "") {
154 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
157 if ($field["Key"] == "PRI") {
158 $fielddata[$field["Field"]]["primary"] = true;
162 if (dbm::is_result($full_columns)) {
163 foreach ($full_columns AS $column) {
164 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
168 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
171 function print_structure($database) {
172 echo "-- ------------------------------------------\n";
173 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
174 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
175 echo "-- ------------------------------------------\n\n\n";
176 foreach ($database AS $name => $structure) {
178 echo "-- TABLE $name\n";
180 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
187 * @brief Print out database error messages
189 * @param string $message Message to be added to the error message
191 * @return string Error message
193 function print_update_error($message) {
194 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
195 dba::errorNo(), dba::errorMessage());
197 return t('Errors encountered performing database changes: ').$message.EOL;
200 function update_structure($verbose, $action, $tables=null, $definition=null) {
204 Config::set('system', 'maintenance', 1);
205 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
210 logger('updating structure', LOGGER_DEBUG);
212 // Get the current structure
215 if (is_null($tables)) {
216 $tables = q("SHOW TABLES");
219 if (dbm::is_result($tables)) {
220 foreach ($tables AS $table) {
221 $table = current($table);
223 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
224 $database[$table] = table_structure($table);
228 // Get the definition
229 if (is_null($definition)) {
230 $definition = db_definition();
233 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
234 if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
235 !(strpos(dba::server_info(), 'MariaDB') !== false)) {
242 foreach ($definition AS $name => $structure) {
243 $is_new_table = False;
246 if (!isset($database[$name])) {
247 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
248 if (!dbm::is_result($r)) {
249 $errors .= print_update_error($name);
251 $is_new_table = True;
256 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
257 if (isset($database[$name]["indexes"][$indexname])) {
258 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
260 $current_index_definition = "__NOT_SET__";
262 $new_index_definition = implode(",",$fieldnames);
263 if ($current_index_definition != $new_index_definition) {
264 if ($fieldnames[0] == "UNIQUE") {
267 $temp_name = "temp-".$name;
274 * Drop the index if it isn't present in the definition
275 * or the definition differ from current status
276 * and index name doesn't start with "local_"
278 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
279 $current_index_definition = implode(",",$fieldnames);
280 if (isset($structure["indexes"][$indexname])) {
281 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
283 $new_index_definition = "__NOT_SET__";
285 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
286 $sql2=db_drop_index($indexname);
288 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
294 // Compare the field structure field by field
295 foreach ($structure["fields"] AS $fieldname => $parameters) {
296 if (!isset($database[$name]["fields"][$fieldname])) {
297 $sql2=db_add_table_field($fieldname, $parameters);
299 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
304 // Compare the field definition
305 $field_definition = $database[$name]["fields"][$fieldname];
307 // Remove the relation data that is used for the referential integrity
308 unset($parameters['relation']);
310 // We change the collation after the indexes had been changed.
311 // This is done to avoid index length problems.
312 // So here we always ensure that there is no need to change it.
313 unset($parameters['Collation']);
314 unset($field_definition['Collation']);
316 $current_field_definition = implode(",", $field_definition);
317 $new_field_definition = implode(",", $parameters);
318 if ($current_field_definition != $new_field_definition) {
319 $sql2 = db_modify_table_field($fieldname, $parameters);
321 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
331 * Create the index if the index don't exists in database
332 * or the definition differ from the current status.
333 * Don't create keys if table is new
335 if (!$is_new_table) {
336 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
337 if (isset($database[$name]["indexes"][$indexname])) {
338 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
340 $current_index_definition = "__NOT_SET__";
342 $new_index_definition = implode(",",$fieldnames);
343 if ($current_index_definition != $new_index_definition) {
344 $sql2 = db_create_index($indexname, $fieldnames);
346 // Fetch the "group by" fields for unique indexes
347 if ($fieldnames[0] == "UNIQUE") {
348 $group_by = db_group_by($indexname, $fieldnames);
352 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
360 if (isset($database[$name]["table_status"]["Collation"])) {
361 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
362 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
365 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
376 // Now have a look at the field collations
377 // Compare the field structure field by field
378 foreach ($structure["fields"] AS $fieldname => $parameters) {
379 // Compare the field definition
380 $field_definition = $database[$name]["fields"][$fieldname];
382 // Define the default collation if not given
383 if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
384 $parameters['Collation'] = 'utf8mb4_general_ci';
386 $parameters['Collation'] = null;
389 if ($field_definition['Collation'] != $parameters['Collation']) {
390 $sql2 = db_modify_table_field($fieldname, $parameters);
391 if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
392 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
401 if (substr($sql3, -2, 2) != "; ") {
406 if ($is_unique && $ignore == '') {
407 foreach ($structure['fields'] AS $fieldname => $parameters) {
408 $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
410 $field_list = rtrim($field_list, ',');
414 // Ensure index conversion to unique removes duplicates
415 if ($is_unique && ($temp_name != $name)) {
417 echo "SET session old_alter_table=1;\n";
419 echo "DROP TABLE IF EXISTS `".$temp_name."`;\n";
420 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
426 if ($is_unique && ($temp_name != $name)) {
428 echo "SET session old_alter_table=0;\n";
430 echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
431 echo "DROP TABLE `".$name."`;\n";
432 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
438 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
440 // Ensure index conversion to unique removes duplicates
441 if ($is_unique && ($temp_name != $name)) {
443 dba::e("SET session old_alter_table=1;");
445 dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
446 if (!dbm::is_result($r)) {
447 $errors .= print_update_error($sql3);
451 $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
452 if (!dbm::is_result($r)) {
453 $errors .= print_update_error($sql3);
460 if (!dbm::is_result($r)) {
461 $errors .= print_update_error($sql3);
463 if ($is_unique && ($temp_name != $name)) {
465 dba::e("SET session old_alter_table=0;");
467 $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
468 if (!dbm::is_result($r)) {
469 $errors .= print_update_error($sql3);
472 $r = dba::e("DROP TABLE `".$name."`;");
473 if (!dbm::is_result($r)) {
474 $errors .= print_update_error($sql3);
477 $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
478 if (!dbm::is_result($r)) {
479 $errors .= print_update_error($sql3);
489 Config::set('system', 'maintenance', 0);
490 Config::set('system', 'maintenance_reason', '');
494 Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
496 Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
502 function db_field_command($parameters, $create = true) {
503 $fieldstruct = $parameters["type"];
505 if (!is_null($parameters["Collation"])) {
506 $fieldstruct .= " COLLATE ".$parameters["Collation"];
509 if ($parameters["not null"])
510 $fieldstruct .= " NOT NULL";
512 if (isset($parameters["default"])) {
513 if (strpos(strtolower($parameters["type"]),"int")!==false) {
514 $fieldstruct .= " DEFAULT ".$parameters["default"];
516 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
519 if ($parameters["extra"] != "")
520 $fieldstruct .= " ".$parameters["extra"];
522 /*if (($parameters["primary"] != "") && $create)
523 $fieldstruct .= " PRIMARY KEY";*/
525 return($fieldstruct);
528 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
536 $primary_keys = array();
537 foreach ($fields AS $fieldname => $field) {
538 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
539 if (x($field,'primary') && $field['primary']!='') {
540 $primary_keys[] = $fieldname;
544 if (!is_null($indexes)) {
545 foreach ($indexes AS $indexname => $fieldnames) {
546 $sql_index = db_create_index($indexname, $fieldnames, "");
547 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
551 $sql = implode(",\n\t", $sql_rows);
553 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
563 function db_add_table_field($fieldname, $parameters) {
564 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
568 function db_modify_table_field($fieldname, $parameters) {
569 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
573 function db_drop_index($indexname) {
574 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
578 function db_create_index($indexname, $fieldnames, $method="ADD") {
580 $method = strtoupper(trim($method));
581 if ($method!="" && $method!="ADD") {
582 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
586 if ($fieldnames[0] == "UNIQUE") {
587 array_shift($fieldnames);
588 $method .= ' UNIQUE';
592 foreach ($fieldnames AS $fieldname) {
596 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
597 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
599 $names .= "`".dbesc($fieldname)."`";
603 if ($indexname == "PRIMARY") {
604 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
608 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
612 function db_group_by($indexname, $fieldnames) {
614 if ($fieldnames[0] != "UNIQUE") {
618 array_shift($fieldnames);
621 foreach ($fieldnames AS $fieldname) {
625 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
626 $names .= "`".dbesc($matches[1])."`";
628 $names .= "`".dbesc($fieldname)."`";
632 $sql = sprintf(" GROUP BY %s", $names);
636 function db_definition() {
640 $database["addon"] = array(
642 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
643 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
644 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
645 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
646 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
647 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
648 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
651 "PRIMARY" => array("id"),
652 "name" => array("UNIQUE", "name"),
655 $database["attach"] = array(
657 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
658 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
659 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
660 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
661 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
662 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
663 "data" => array("type" => "longblob", "not null" => "1"),
664 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
665 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
666 "allow_cid" => array("type" => "mediumtext"),
667 "allow_gid" => array("type" => "mediumtext"),
668 "deny_cid" => array("type" => "mediumtext"),
669 "deny_gid" => array("type" => "mediumtext"),
672 "PRIMARY" => array("id"),
675 $database["auth_codes"] = array(
677 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
678 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
679 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
680 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
681 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
684 "PRIMARY" => array("id"),
687 $database["cache"] = array(
689 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
690 "v" => array("type" => "mediumtext"),
691 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
692 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
695 "PRIMARY" => array("k"),
696 "expire_mode_updated" => array("expire_mode", "updated"),
699 $database["challenge"] = array(
701 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
702 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
703 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
704 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
705 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
706 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
709 "PRIMARY" => array("id"),
712 $database["clients"] = array(
714 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
715 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
716 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
717 "name" => array("type" => "text"),
718 "icon" => array("type" => "text"),
719 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
722 "PRIMARY" => array("client_id"),
725 $database["config"] = array(
727 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
728 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
729 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
730 "v" => array("type" => "mediumtext"),
733 "PRIMARY" => array("id"),
734 "cat_k" => array("UNIQUE", "cat", "k"),
737 $database["contact"] = array(
739 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
740 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
741 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
742 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
743 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
744 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
745 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
746 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "about" => array("type" => "text"),
751 "keywords" => array("type" => "text"),
752 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
753 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "photo" => array("type" => "text"),
757 "thumb" => array("type" => "text"),
758 "micro" => array("type" => "text"),
759 "site-pubkey" => array("type" => "text"),
760 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
761 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
762 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
763 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
764 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
765 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
766 "pubkey" => array("type" => "text"),
767 "prvkey" => array("type" => "text"),
768 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
769 "request" => array("type" => "text"),
770 "notify" => array("type" => "text"),
771 "poll" => array("type" => "text"),
772 "confirm" => array("type" => "text"),
773 "poco" => array("type" => "text"),
774 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
775 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
776 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
777 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
778 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
779 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
780 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
781 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
782 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
783 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
784 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
785 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
786 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
787 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
788 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
789 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
790 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
792 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
793 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
794 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
795 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
796 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
797 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
798 "reason" => array("type" => "text"),
799 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
800 "info" => array("type" => "mediumtext"),
801 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
802 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
803 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
804 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
805 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
806 "ffi_keyword_blacklist" => array("type" => "text"),
809 "PRIMARY" => array("id"),
810 "uid_name" => array("uid", "name(190)"),
811 "self_uid" => array("self", "uid"),
812 "alias_uid" => array("alias(32)", "uid"),
813 "pending_uid" => array("pending", "uid"),
814 "blocked_uid" => array("blocked", "uid"),
815 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
816 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
817 "addr_uid" => array("addr(32)", "uid"),
818 "nurl_uid" => array("nurl(32)", "uid"),
819 "nick_uid" => array("nick(32)", "uid"),
820 "dfrn-id" => array("dfrn-id"),
821 "issued-id" => array("issued-id"),
824 $database["conv"] = array(
826 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
827 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
828 "recips" => array("type" => "text"),
829 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
830 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
831 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
832 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
833 "subject" => array("type" => "text"),
836 "PRIMARY" => array("id"),
837 "uid" => array("uid"),
840 $database["conversation"] = array(
842 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
843 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
844 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
845 "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
846 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
847 "source" => array("type" => "mediumtext"),
848 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
851 "PRIMARY" => array("item-uri"),
852 "conversation-uri" => array("conversation-uri"),
855 $database["event"] = array(
857 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
858 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
859 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
860 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
861 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
862 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
863 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
864 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
865 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
866 "summary" => array("type" => "text"),
867 "desc" => array("type" => "text"),
868 "location" => array("type" => "text"),
869 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
871 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
872 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
873 "allow_cid" => array("type" => "mediumtext"),
874 "allow_gid" => array("type" => "mediumtext"),
875 "deny_cid" => array("type" => "mediumtext"),
876 "deny_gid" => array("type" => "mediumtext"),
879 "PRIMARY" => array("id"),
880 "uid_start" => array("uid", "start"),
883 $database["fcontact"] = array(
885 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
886 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
889 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
892 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
893 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
894 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
895 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
896 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
897 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
898 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
899 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "pubkey" => array("type" => "text"),
901 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
904 "PRIMARY" => array("id"),
905 "addr" => array("addr(32)"),
906 "url" => array("UNIQUE", "url(190)"),
909 $database["ffinder"] = array(
911 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
912 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
913 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
914 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
917 "PRIMARY" => array("id"),
920 $database["fserver"] = array(
922 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
923 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
924 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
925 "key" => array("type" => "text"),
928 "PRIMARY" => array("id"),
929 "server" => array("server(32)"),
932 $database["fsuggest"] = array(
934 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
935 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
936 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
937 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
938 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
939 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
940 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
941 "note" => array("type" => "text"),
942 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
945 "PRIMARY" => array("id"),
948 $database["gcign"] = array(
950 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
951 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
952 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
955 "PRIMARY" => array("id"),
956 "uid" => array("uid"),
957 "gcid" => array("gcid"),
960 $database["gcontact"] = array(
962 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
963 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
964 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
965 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
966 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
967 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
968 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
969 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
970 "updated" => array("type" => "datetime", "default" => NULL_DATE),
971 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
972 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
973 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
974 "about" => array("type" => "text"),
975 "keywords" => array("type" => "text"),
976 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
977 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
978 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
979 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
980 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
981 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
982 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
983 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
984 "notify" => array("type" => "text"),
985 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
986 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
987 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
990 "PRIMARY" => array("id"),
991 "nurl" => array("UNIQUE", "nurl(190)"),
992 "name" => array("name(64)"),
993 "nick" => array("nick(32)"),
994 "addr" => array("addr(64)"),
995 "hide_network_updated" => array("hide", "network(4)", "updated"),
996 "updated" => array("updated"),
999 $database["glink"] = array(
1001 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1002 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1003 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1004 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1005 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1006 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1009 "PRIMARY" => array("id"),
1010 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
1011 "gcid" => array("gcid"),
1014 $database["group"] = array(
1016 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1017 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1018 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1019 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1020 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "PRIMARY" => array("id"),
1024 "uid" => array("uid"),
1027 $database["group_member"] = array(
1029 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1030 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1031 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
1032 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1035 "PRIMARY" => array("id"),
1036 "contactid" => array("contact-id"),
1037 "gid_contactid" => array("gid", "contact-id"),
1038 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1041 $database["gserver"] = array(
1043 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1044 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "info" => array("type" => "text"),
1049 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1050 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1051 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1052 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1053 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1054 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1055 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1056 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1057 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1060 "PRIMARY" => array("id"),
1061 "nurl" => array("UNIQUE", "nurl(190)"),
1064 $database["hook"] = array(
1066 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1067 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1068 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1069 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1070 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1073 "PRIMARY" => array("id"),
1074 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1077 $database["intro"] = array(
1079 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1080 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1081 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
1082 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1083 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1084 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1085 "note" => array("type" => "text"),
1086 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1087 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1088 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1089 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1092 "PRIMARY" => array("id"),
1095 $database["item"] = array(
1097 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
1098 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1099 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1100 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1101 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1102 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1103 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1105 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1106 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1107 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1108 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1109 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1110 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1111 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1112 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1113 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1114 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1115 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1116 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1118 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1119 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1120 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1121 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1122 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1124 "body" => array("type" => "mediumtext"),
1125 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1126 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1127 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1128 "object" => array("type" => "text"),
1129 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1130 "target" => array("type" => "text"),
1131 "postopts" => array("type" => "text"),
1132 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1133 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
1135 "tag" => array("type" => "mediumtext"),
1136 "attach" => array("type" => "mediumtext"),
1137 "inform" => array("type" => "mediumtext"),
1138 "file" => array("type" => "mediumtext"),
1139 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1140 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1141 "allow_cid" => array("type" => "mediumtext"),
1142 "allow_gid" => array("type" => "mediumtext"),
1143 "deny_cid" => array("type" => "mediumtext"),
1144 "deny_gid" => array("type" => "mediumtext"),
1145 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1146 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1147 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1148 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1149 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1150 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1151 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1152 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1153 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1154 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1155 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1156 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1157 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1158 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1159 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1160 "rendered-html" => array("type" => "mediumtext"),
1161 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1164 "PRIMARY" => array("id"),
1165 "guid" => array("guid"),
1166 "uri" => array("uri"),
1167 "parent" => array("parent"),
1168 "parent-uri" => array("parent-uri"),
1169 "extid" => array("extid"),
1170 "uid_id" => array("uid","id"),
1171 "uid_contactid_id" => array("uid","contact-id","id"),
1172 "uid_created" => array("uid","created"),
1173 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1174 "uid_network_received" => array("uid","network(4)","received"),
1175 "uid_network_commented" => array("uid","network(4)","commented"),
1176 "uid_thrparent" => array("uid","thr-parent(190)"),
1177 "uid_parenturi" => array("uid","parent-uri(190)"),
1178 "uid_contactid_created" => array("uid","contact-id","created"),
1179 "authorid_created" => array("author-id","created"),
1180 "ownerid" => array("owner-id"),
1181 "uid_uri" => array("uid", "uri(190)"),
1182 "resource-id" => array("resource-id"),
1183 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1184 "uid_type_changed" => array("uid","type(190)","changed"),
1185 "contactid_verb" => array("contact-id","verb(190)"),
1186 "deleted_changed" => array("deleted","changed"),
1187 "uid_wall_changed" => array("uid","wall","changed"),
1188 "uid_eventid" => array("uid","event-id"),
1189 "uid_authorlink" => array("uid","author-link(190)"),
1190 "uid_ownerlink" => array("uid","owner-link(190)"),
1193 $database["item_id"] = array(
1195 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1196 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1197 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1198 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1199 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1202 "PRIMARY" => array("id"),
1203 "uid" => array("uid"),
1204 "sid" => array("sid"),
1205 "service" => array("service(32)"),
1206 "iid" => array("iid"),
1209 $database["locks"] = array(
1211 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1212 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1213 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1214 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1217 "PRIMARY" => array("id"),
1220 $database["mail"] = array(
1222 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1223 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1224 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1225 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1226 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1227 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1228 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
1229 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
1230 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1231 "body" => array("type" => "mediumtext"),
1232 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1233 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1234 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1235 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1236 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1237 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1238 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1241 "PRIMARY" => array("id"),
1242 "uid_seen" => array("uid", "seen"),
1243 "convid" => array("convid"),
1244 "uri" => array("uri(64)"),
1245 "parent-uri" => array("parent-uri(64)"),
1246 "contactid" => array("contact-id"),
1249 $database["mailacct"] = array(
1251 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1252 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1253 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1254 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1255 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1256 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1257 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1258 "pass" => array("type" => "text"),
1259 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1260 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1261 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1262 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1263 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1266 "PRIMARY" => array("id"),
1269 $database["manage"] = array(
1271 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1272 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1273 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1276 "PRIMARY" => array("id"),
1277 "uid_mid" => array("UNIQUE", "uid","mid"),
1280 $database["notify"] = array(
1282 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1283 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1284 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1285 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1286 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1287 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1288 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1289 "msg" => array("type" => "mediumtext"),
1290 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1291 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1292 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1293 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1294 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1295 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1296 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1297 "name_cache" => array("type" => "tinytext"),
1298 "msg_cache" => array("type" => "mediumtext")
1301 "PRIMARY" => array("id"),
1302 "hash_uid" => array("hash", "uid"),
1303 "seen_uid_date" => array("seen", "uid", "date"),
1304 "uid_date" => array("uid", "date"),
1305 "uid_type_link" => array("uid", "type", "link(190)"),
1308 $database["notify-threads"] = array(
1310 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1311 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
1312 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1313 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1314 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1317 "PRIMARY" => array("id"),
1320 $database["oembed"] = array(
1322 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1323 "content" => array("type" => "mediumtext"),
1324 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1327 "PRIMARY" => array("url"),
1328 "created" => array("created"),
1331 $database["parsed_url"] = array(
1333 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1334 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1335 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1336 "content" => array("type" => "mediumtext"),
1337 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1340 "PRIMARY" => array("url", "guessing", "oembed"),
1341 "created" => array("created"),
1344 $database["pconfig"] = array(
1346 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1347 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1348 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1349 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1350 "v" => array("type" => "mediumtext"),
1353 "PRIMARY" => array("id"),
1354 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1357 $database["photo"] = array(
1359 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1360 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1361 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1362 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1363 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1364 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1365 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1366 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1367 "desc" => array("type" => "text"),
1368 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1369 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1370 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1371 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1372 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1373 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1374 "data" => array("type" => "mediumblob", "not null" => "1"),
1375 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1376 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1377 "allow_cid" => array("type" => "mediumtext"),
1378 "allow_gid" => array("type" => "mediumtext"),
1379 "deny_cid" => array("type" => "mediumtext"),
1380 "deny_gid" => array("type" => "mediumtext"),
1383 "PRIMARY" => array("id"),
1384 "contactid" => array("contact-id"),
1385 "uid_contactid" => array("uid", "contact-id"),
1386 "uid_profile" => array("uid", "profile"),
1387 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1388 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1389 "resource-id" => array("resource-id(64)"),
1392 $database["poll"] = array(
1394 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1395 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1396 "q0" => array("type" => "text"),
1397 "q1" => array("type" => "text"),
1398 "q2" => array("type" => "text"),
1399 "q3" => array("type" => "text"),
1400 "q4" => array("type" => "text"),
1401 "q5" => array("type" => "text"),
1402 "q6" => array("type" => "text"),
1403 "q7" => array("type" => "text"),
1404 "q8" => array("type" => "text"),
1405 "q9" => array("type" => "text"),
1408 "PRIMARY" => array("id"),
1409 "uid" => array("uid"),
1412 $database["poll_result"] = array(
1414 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1415 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
1416 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1419 "PRIMARY" => array("id"),
1420 "poll_id" => array("poll_id"),
1421 "choice" => array("choice"),
1424 $database["process"] = array(
1426 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1427 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1428 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1431 "PRIMARY" => array("pid"),
1432 "command" => array("command"),
1435 $database["profile"] = array(
1437 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1438 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1439 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1440 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1441 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1442 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1443 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1444 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1445 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1446 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1447 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1448 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1449 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1450 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1451 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1452 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1453 "with" => array("type" => "text"),
1454 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1455 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1456 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1457 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1458 "pub_keywords" => array("type" => "text"),
1459 "prv_keywords" => array("type" => "text"),
1460 "likes" => array("type" => "text"),
1461 "dislikes" => array("type" => "text"),
1462 "about" => array("type" => "text"),
1463 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1464 "music" => array("type" => "text"),
1465 "book" => array("type" => "text"),
1466 "tv" => array("type" => "text"),
1467 "film" => array("type" => "text"),
1468 "interest" => array("type" => "text"),
1469 "romance" => array("type" => "text"),
1470 "work" => array("type" => "text"),
1471 "education" => array("type" => "text"),
1472 "contact" => array("type" => "text"),
1473 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1474 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1475 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1476 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1477 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1478 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1481 "PRIMARY" => array("id"),
1482 "uid_is-default" => array("uid", "is-default"),
1485 $database["profile_check"] = array(
1487 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1488 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1489 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1490 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1491 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1492 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1495 "PRIMARY" => array("id"),
1498 $database["push_subscriber"] = array(
1500 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1501 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1502 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1503 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1504 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1505 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1506 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1507 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1510 "PRIMARY" => array("id"),
1513 $database["queue"] = array(
1515 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1516 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1517 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1518 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1519 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1520 "content" => array("type" => "mediumtext"),
1521 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1524 "PRIMARY" => array("id"),
1525 "cid" => array("cid"),
1526 "created" => array("created"),
1527 "last" => array("last"),
1528 "network" => array("network"),
1529 "batch" => array("batch"),
1532 $database["register"] = array(
1534 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1535 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1536 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1537 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1538 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1539 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1540 "note" => array("type" => "text"),
1543 "PRIMARY" => array("id"),
1546 $database["search"] = array(
1548 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1549 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1550 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1553 "PRIMARY" => array("id"),
1554 "uid" => array("uid"),
1557 $database["session"] = array(
1559 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1560 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1561 "data" => array("type" => "text"),
1562 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1565 "PRIMARY" => array("id"),
1566 "sid" => array("sid(64)"),
1567 "expire" => array("expire"),
1570 $database["sign"] = array(
1572 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1573 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1574 "signed_text" => array("type" => "mediumtext"),
1575 "signature" => array("type" => "text"),
1576 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1579 "PRIMARY" => array("id"),
1580 "iid" => array("UNIQUE", "iid"),
1583 $database["spam"] = array(
1585 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1586 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1587 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1588 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1589 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1590 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1593 "PRIMARY" => array("id"),
1594 "uid" => array("uid"),
1595 "spam" => array("spam"),
1596 "ham" => array("ham"),
1597 "term" => array("term"),
1600 $database["term"] = array(
1602 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1603 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
1604 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1605 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1606 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1607 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1608 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1609 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1610 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1611 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1612 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1613 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1616 "PRIMARY" => array("tid"),
1617 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1618 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1619 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1620 "guid" => array("guid(64)"),
1623 $database["thread"] = array(
1625 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
1626 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1627 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1628 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
1629 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1630 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
1631 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1632 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1633 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1634 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1635 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1636 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1637 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1638 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1639 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1640 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1641 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1642 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1643 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1644 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1645 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1646 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1647 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1648 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1649 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1650 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1653 "PRIMARY" => array("iid"),
1654 "uid_network_commented" => array("uid","network","commented"),
1655 "uid_network_created" => array("uid","network","created"),
1656 "uid_contactid_commented" => array("uid","contact-id","commented"),
1657 "uid_contactid_created" => array("uid","contact-id","created"),
1658 "contactid" => array("contact-id"),
1659 "ownerid" => array("owner-id"),
1660 "authorid" => array("author-id"),
1661 "uid_created" => array("uid","created"),
1662 "uid_commented" => array("uid","commented"),
1663 "uid_wall_created" => array("uid","wall","created"),
1664 "private_wall_received" => array("private","wall","received"),
1667 $database["tokens"] = array(
1669 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1670 "secret" => array("type" => "text"),
1671 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
1672 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1673 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1674 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
1677 "PRIMARY" => array("id"),
1680 $database["user"] = array(
1682 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1683 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1684 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1685 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1686 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1687 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1688 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1689 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1690 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1691 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1692 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1693 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1694 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1695 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1696 "pubkey" => array("type" => "text"),
1697 "prvkey" => array("type" => "text"),
1698 "spubkey" => array("type" => "text"),
1699 "sprvkey" => array("type" => "text"),
1700 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1701 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1702 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1703 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1704 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1705 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1706 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1707 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1708 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1709 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1710 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1711 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1712 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1713 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1714 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1715 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1716 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1717 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1718 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1719 "allow_cid" => array("type" => "mediumtext"),
1720 "allow_gid" => array("type" => "mediumtext"),
1721 "deny_cid" => array("type" => "mediumtext"),
1722 "deny_gid" => array("type" => "mediumtext"),
1723 "openidserver" => array("type" => "text"),
1726 "PRIMARY" => array("uid"),
1727 "nickname" => array("nickname(32)"),
1730 $database["userd"] = array(
1732 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1733 "username" => array("type" => "varchar(255)", "not null" => "1"),
1736 "PRIMARY" => array("id"),
1737 "username" => array("username(32)"),
1740 $database["workerqueue"] = array(
1742 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1743 "parameter" => array("type" => "text"),
1744 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1745 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1746 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1747 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1748 "done" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1751 "PRIMARY" => array("id"),
1752 "pid" => array("pid"),
1753 "parameter" => array("parameter(64)"),
1754 "priority_created" => array("priority", "created"),
1755 "executed" => array("executed"),
1764 * run from command line
1766 function dbstructure_run(&$argv, &$argc) {
1770 $a = new App(dirname(__DIR__));
1773 @include ".htconfig.php";
1774 require_once "include/dba.php";
1775 dba::connect($db_host, $db_user, $db_pass, $db_data);
1776 unset($db_host, $db_user, $db_pass, $db_data);
1781 update_structure(true, false);
1784 update_structure(true, true);
1786 $build = get_config('system','build');
1788 set_config('system', 'build', DB_UPDATE_VERSION);
1789 $build = DB_UPDATE_VERSION;
1792 $stored = intval($build);
1793 $current = intval(DB_UPDATE_VERSION);
1795 // run any left update_nnnn functions in update.php
1796 for ($x = $stored; $x < $current; $x ++) {
1797 $r = run_update_function($x);
1803 set_config('system','build',DB_UPDATE_VERSION);
1806 print_structure(db_definition());
1809 convert_to_innodb();
1816 echo $argv[0]." <command>\n";
1819 echo "dryrun show database update schema queries without running them\n";
1820 echo "update update database schema\n";
1821 echo "dumpsql dump database schema\n";
1822 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1827 if (array_search(__FILE__,get_included_files())===0) {
1828 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);