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 // We change the collation after the indexes had been changed.
304 // This is done to avoid index length problems.
305 // So here we always ensure that there is no need to change it.
306 unset($parameters['Collation']);
307 unset($field_definition['Collation']);
309 $current_field_definition = implode(",", $field_definition);
310 $new_field_definition = implode(",", $parameters);
311 if ($current_field_definition != $new_field_definition) {
312 $sql2 = db_modify_table_field($fieldname, $parameters);
314 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
324 * Create the index if the index don't exists in database
325 * or the definition differ from the current status.
326 * Don't create keys if table is new
328 if (!$is_new_table) {
329 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
330 if (isset($database[$name]["indexes"][$indexname])) {
331 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
333 $current_index_definition = "__NOT_SET__";
335 $new_index_definition = implode(",",$fieldnames);
336 if ($current_index_definition != $new_index_definition) {
337 $sql2 = db_create_index($indexname, $fieldnames);
339 // Fetch the "group by" fields for unique indexes
340 if ($fieldnames[0] == "UNIQUE") {
341 $group_by = db_group_by($indexname, $fieldnames);
345 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
353 if (isset($database[$name]["table_status"]["Collation"])) {
354 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
355 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
358 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
369 // Now have a look at the field collations
370 // Compare the field structure field by field
371 foreach ($structure["fields"] AS $fieldname => $parameters) {
372 // Compare the field definition
373 $field_definition = $database[$name]["fields"][$fieldname];
375 // Define the default collation if not given
376 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
377 $parameters['Collation'] = 'utf8mb4_general_ci';
379 $parameters['Collation'] = null;
382 if ($field_definition['Collation'] != $parameters['Collation']) {
383 $sql2 = db_modify_table_field($fieldname, $parameters);
384 if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
385 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
394 if (substr($sql3, -2, 2) != "; ") {
399 // Ensure index conversion to unique removes duplicates
402 echo "SET session old_alter_table=1;\n";
404 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
412 echo "SET session old_alter_table=0;\n";
414 echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
415 echo "DROP TABLE `".$name."`;\n";
416 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
422 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
424 // Ensure index conversion to unique removes duplicates
427 $db->q("SET session old_alter_table=1;");
429 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
430 if (!dbm::is_result($r)) {
431 $errors .= print_update_error($db, $sql3);
438 if (!dbm::is_result($r)) {
439 $errors .= print_update_error($db, $sql3);
443 $db->q("SET session old_alter_table=0;");
445 $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
446 if (!dbm::is_result($r)) {
447 $errors .= print_update_error($db, $sql3);
450 $r = $db->q("DROP TABLE `".$name."`;");
451 if (!dbm::is_result($r)) {
452 $errors .= print_update_error($db, $sql3);
455 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
456 if (!dbm::is_result($r)) {
457 $errors .= print_update_error($db, $sql3);
467 Config::set('system', 'maintenance', 0);
468 Config::set('system', 'maintenance_reason', '');
474 function db_field_command($parameters, $create = true) {
475 $fieldstruct = $parameters["type"];
477 if (!is_null($parameters["Collation"])) {
478 $fieldstruct .= " COLLATE ".$parameters["Collation"];
481 if ($parameters["not null"])
482 $fieldstruct .= " NOT NULL";
484 if (isset($parameters["default"])) {
485 if (strpos(strtolower($parameters["type"]),"int")!==false) {
486 $fieldstruct .= " DEFAULT ".$parameters["default"];
488 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
491 if ($parameters["extra"] != "")
492 $fieldstruct .= " ".$parameters["extra"];
494 /*if (($parameters["primary"] != "") AND $create)
495 $fieldstruct .= " PRIMARY KEY";*/
497 return($fieldstruct);
500 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
508 $primary_keys = array();
509 foreach ($fields AS $fieldname => $field) {
510 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
511 if (x($field,'primary') and $field['primary']!='') {
512 $primary_keys[] = $fieldname;
516 if (!is_null($indexes)) {
517 foreach ($indexes AS $indexname => $fieldnames) {
518 $sql_index = db_create_index($indexname, $fieldnames, "");
519 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
523 $sql = implode(",\n\t", $sql_rows);
525 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
535 function db_add_table_field($fieldname, $parameters) {
536 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
540 function db_modify_table_field($fieldname, $parameters) {
541 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
545 function db_drop_index($indexname) {
546 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
550 function db_create_index($indexname, $fieldnames, $method="ADD") {
552 $method = strtoupper(trim($method));
553 if ($method!="" && $method!="ADD") {
554 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
558 if ($fieldnames[0] == "UNIQUE") {
559 array_shift($fieldnames);
560 $method .= ' UNIQUE';
564 foreach ($fieldnames AS $fieldname) {
568 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
569 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
571 $names .= "`".dbesc($fieldname)."`";
575 if ($indexname == "PRIMARY") {
576 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
580 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
584 function db_group_by($indexname, $fieldnames) {
586 if ($fieldnames[0] != "UNIQUE") {
590 array_shift($fieldnames);
593 foreach ($fieldnames AS $fieldname) {
597 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
598 $names .= "`".dbesc($matches[1])."`";
600 $names .= "`".dbesc($fieldname)."`";
604 $sql = sprintf(" GROUP BY %s", $names);
608 function db_definition() {
612 $database["addon"] = array(
614 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
615 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
616 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
617 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
618 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
619 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
620 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
623 "PRIMARY" => array("id"),
624 "name" => array("UNIQUE", "name"),
627 $database["attach"] = array(
629 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
630 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
631 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
632 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
633 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
634 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
635 "data" => array("type" => "longblob", "not null" => "1"),
636 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
637 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
638 "allow_cid" => array("type" => "mediumtext"),
639 "allow_gid" => array("type" => "mediumtext"),
640 "deny_cid" => array("type" => "mediumtext"),
641 "deny_gid" => array("type" => "mediumtext"),
644 "PRIMARY" => array("id"),
647 $database["auth_codes"] = array(
649 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
650 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
651 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
652 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
653 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
656 "PRIMARY" => array("id"),
659 $database["cache"] = array(
661 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
662 "v" => array("type" => "mediumtext"),
663 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
664 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
667 "PRIMARY" => array("k"),
668 "expire_mode_updated" => array("expire_mode", "updated"),
671 $database["challenge"] = array(
673 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
674 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
675 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
676 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
677 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
678 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
681 "PRIMARY" => array("id"),
684 $database["clients"] = array(
686 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
687 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
688 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
689 "name" => array("type" => "text"),
690 "icon" => array("type" => "text"),
691 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
694 "PRIMARY" => array("client_id"),
697 $database["config"] = array(
699 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
700 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
701 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
702 "v" => array("type" => "mediumtext"),
705 "PRIMARY" => array("id"),
706 "cat_k" => array("UNIQUE", "cat", "k"),
709 $database["contact"] = array(
711 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
712 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
713 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
714 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
715 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
716 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
717 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
718 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
719 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
720 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
721 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
722 "about" => array("type" => "text"),
723 "keywords" => array("type" => "text"),
724 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
725 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
726 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
727 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
728 "photo" => array("type" => "text"),
729 "thumb" => array("type" => "text"),
730 "micro" => array("type" => "text"),
731 "site-pubkey" => array("type" => "text"),
732 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
735 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "pubkey" => array("type" => "text"),
739 "prvkey" => array("type" => "text"),
740 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
741 "request" => array("type" => "text"),
742 "notify" => array("type" => "text"),
743 "poll" => array("type" => "text"),
744 "confirm" => array("type" => "text"),
745 "poco" => array("type" => "text"),
746 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
747 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
748 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
749 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
750 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
751 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
752 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
753 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
754 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
755 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
756 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
757 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
758 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
759 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
760 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
761 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
762 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
763 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
764 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
765 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
766 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
767 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
768 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
769 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
770 "reason" => array("type" => "text"),
771 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
772 "info" => array("type" => "mediumtext"),
773 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
774 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
775 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
776 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
777 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
778 "ffi_keyword_blacklist" => array("type" => "text"),
781 "PRIMARY" => array("id"),
782 "uid_name" => array("uid", "name(190)"),
783 "self_uid" => array("self", "uid"),
784 "alias_uid" => array("alias(32)", "uid"),
785 "pending_uid" => array("pending", "uid"),
786 "blocked_uid" => array("blocked", "uid"),
787 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
788 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
789 "addr_uid" => array("addr(32)", "uid"),
790 "nurl_uid" => array("nurl(32)", "uid"),
791 "nick_uid" => array("nick(32)", "uid"),
792 "dfrn-id" => array("dfrn-id"),
793 "issued-id" => array("issued-id"),
796 $database["conv"] = array(
798 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
799 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
800 "recips" => array("type" => "text"),
801 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
802 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
803 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
804 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
805 "subject" => array("type" => "text"),
808 "PRIMARY" => array("id"),
809 "uid" => array("uid"),
812 $database["conversation"] = array(
814 "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
815 "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
816 "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
817 "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
818 "source" => array("type" => "mediumtext"),
821 "PRIMARY" => array("item-uri"),
822 "conversation-uri" => array("conversation-uri"),
825 $database["event"] = array(
827 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
828 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
829 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
830 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
831 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
832 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
833 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
834 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
835 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
836 "summary" => array("type" => "text"),
837 "desc" => array("type" => "text"),
838 "location" => array("type" => "text"),
839 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
840 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
841 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
842 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
843 "allow_cid" => array("type" => "mediumtext"),
844 "allow_gid" => array("type" => "mediumtext"),
845 "deny_cid" => array("type" => "mediumtext"),
846 "deny_gid" => array("type" => "mediumtext"),
849 "PRIMARY" => array("id"),
850 "uid_start" => array("uid", "start"),
853 $database["fcontact"] = array(
855 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
856 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
857 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
858 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
859 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
860 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
861 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
862 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
863 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
864 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
865 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
866 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
867 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
868 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
869 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "pubkey" => array("type" => "text"),
871 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
874 "PRIMARY" => array("id"),
875 "addr" => array("addr(32)"),
876 "url" => array("url"),
879 $database["ffinder"] = array(
881 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
882 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
883 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
884 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
887 "PRIMARY" => array("id"),
890 $database["fserver"] = array(
892 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
893 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
894 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
895 "key" => array("type" => "text"),
898 "PRIMARY" => array("id"),
899 "server" => array("server(32)"),
902 $database["fsuggest"] = array(
904 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
905 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
906 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
907 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
908 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
909 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
910 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
911 "note" => array("type" => "text"),
912 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
915 "PRIMARY" => array("id"),
918 $database["gcign"] = array(
920 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
921 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
922 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
925 "PRIMARY" => array("id"),
926 "uid" => array("uid"),
927 "gcid" => array("gcid"),
930 $database["gcontact"] = array(
932 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
933 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
934 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
935 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
936 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
937 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
938 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
939 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
940 "updated" => array("type" => "datetime", "default" => NULL_DATE),
941 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
942 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
943 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
944 "about" => array("type" => "text"),
945 "keywords" => array("type" => "text"),
946 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
947 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
948 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
949 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
950 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
951 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
952 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
953 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
954 "notify" => array("type" => "text"),
955 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
956 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
957 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "PRIMARY" => array("id"),
961 "nurl" => array("nurl(64)"),
962 "name" => array("name(64)"),
963 "nick" => array("nick(32)"),
964 "addr" => array("addr(64)"),
965 "hide_network_updated" => array("hide", "network(4)", "updated"),
966 "updated" => array("updated"),
969 $database["glink"] = array(
971 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
972 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
973 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
974 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
975 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
976 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
979 "PRIMARY" => array("id"),
980 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
981 "gcid" => array("gcid"),
984 $database["group"] = array(
986 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
987 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
988 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
989 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
990 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
993 "PRIMARY" => array("id"),
994 "uid" => array("uid"),
997 $database["group_member"] = 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"),
1001 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1002 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1005 "PRIMARY" => array("id"),
1006 "contactid" => array("contact-id"),
1007 "gid_contactid" => array("gid", "contact-id"),
1008 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
1011 $database["gserver"] = array(
1013 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1014 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1015 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1016 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1017 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1018 "info" => array("type" => "text"),
1019 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1020 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1021 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1022 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1023 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1024 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1025 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
1026 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
1027 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
1030 "PRIMARY" => array("id"),
1031 "nurl" => array("nurl(32)"),
1034 $database["hook"] = array(
1036 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1037 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1039 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1040 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1043 "PRIMARY" => array("id"),
1044 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1047 $database["intro"] = array(
1049 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1050 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1051 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1052 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1053 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1054 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1055 "note" => array("type" => "text"),
1056 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1057 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1058 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1059 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1062 "PRIMARY" => array("id"),
1065 $database["item"] = array(
1067 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1068 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1069 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1070 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1071 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1072 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1073 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1074 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1075 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1076 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1077 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1078 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1079 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1080 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1081 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1082 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1083 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1084 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1085 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1086 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1087 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1088 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1089 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1090 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1091 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1092 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "body" => array("type" => "mediumtext"),
1095 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1096 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1097 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1098 "object" => array("type" => "text"),
1099 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1100 "target" => array("type" => "text"),
1101 "postopts" => array("type" => "text"),
1102 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1105 "tag" => array("type" => "mediumtext"),
1106 "attach" => array("type" => "mediumtext"),
1107 "inform" => array("type" => "mediumtext"),
1108 "file" => array("type" => "mediumtext"),
1109 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1110 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1111 "allow_cid" => array("type" => "mediumtext"),
1112 "allow_gid" => array("type" => "mediumtext"),
1113 "deny_cid" => array("type" => "mediumtext"),
1114 "deny_gid" => array("type" => "mediumtext"),
1115 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1116 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1117 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1118 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1119 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1120 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1121 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1122 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1123 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1124 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1125 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1126 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1127 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1128 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1129 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1130 "rendered-html" => array("type" => "mediumtext"),
1131 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1134 "PRIMARY" => array("id"),
1135 "guid" => array("guid"),
1136 "uri" => array("uri"),
1137 "parent" => array("parent"),
1138 "parent-uri" => array("parent-uri"),
1139 "extid" => array("extid"),
1140 "uid_id" => array("uid","id"),
1141 "uid_contactid_id" => array("uid","contact-id","id"),
1142 "uid_created" => array("uid","created"),
1143 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1144 "uid_network_received" => array("uid","network(4)","received"),
1145 "uid_network_commented" => array("uid","network(4)","commented"),
1146 "uid_thrparent" => array("uid","thr-parent(190)"),
1147 "uid_parenturi" => array("uid","parent-uri(190)"),
1148 "uid_contactid_created" => array("uid","contact-id","created"),
1149 "authorid_created" => array("author-id","created"),
1150 "uid_uri" => array("uid", "uri(190)"),
1151 "resource-id" => array("resource-id"),
1152 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1153 "uid_type_changed" => array("uid","type(190)","changed"),
1154 "contactid_verb" => array("contact-id","verb(190)"),
1155 "deleted_changed" => array("deleted","changed"),
1156 "uid_wall_changed" => array("uid","wall","changed"),
1157 "uid_eventid" => array("uid","event-id"),
1158 "uid_authorlink" => array("uid","author-link(190)"),
1159 "uid_ownerlink" => array("uid","owner-link(190)"),
1162 $database["item_id"] = array(
1164 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1165 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1166 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1167 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1168 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1171 "PRIMARY" => array("id"),
1172 "uid" => array("uid"),
1173 "sid" => array("sid"),
1174 "service" => array("service(32)"),
1175 "iid" => array("iid"),
1178 $database["locks"] = array(
1180 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1181 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1182 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1183 "created" => array("type" => "datetime", "default" => NULL_DATE),
1186 "PRIMARY" => array("id"),
1189 $database["mail"] = array(
1191 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1192 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1193 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1194 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1195 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1196 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1197 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1198 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1199 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1200 "body" => array("type" => "mediumtext"),
1201 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1202 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1203 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1204 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1205 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1206 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1207 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1210 "PRIMARY" => array("id"),
1211 "uid_seen" => array("uid", "seen"),
1212 "convid" => array("convid"),
1213 "uri" => array("uri(64)"),
1214 "parent-uri" => array("parent-uri(64)"),
1217 $database["mailacct"] = array(
1219 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1220 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1221 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1222 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1223 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1224 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1225 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1226 "pass" => array("type" => "text"),
1227 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1228 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1229 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1230 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1231 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1234 "PRIMARY" => array("id"),
1237 $database["manage"] = array(
1239 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1240 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1241 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1244 "PRIMARY" => array("id"),
1245 "uid_mid" => array("UNIQUE", "uid","mid"),
1248 $database["notify"] = array(
1250 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1251 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1252 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1253 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1254 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1255 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1256 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1257 "msg" => array("type" => "mediumtext"),
1258 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1259 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1260 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1261 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1262 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1263 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1264 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1265 "name_cache" => array("type" => "tinytext"),
1266 "msg_cache" => array("type" => "mediumtext")
1269 "PRIMARY" => array("id"),
1270 "hash_uid" => array("hash", "uid"),
1271 "seen_uid_date" => array("seen", "uid", "date"),
1272 "uid_date" => array("uid", "date"),
1273 "uid_type_link" => array("uid", "type", "link(190)"),
1276 $database["notify-threads"] = array(
1278 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1279 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1280 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1281 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1282 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1285 "PRIMARY" => array("id"),
1288 $database["oembed"] = array(
1290 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1291 "content" => array("type" => "mediumtext"),
1292 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1295 "PRIMARY" => array("url"),
1296 "created" => array("created"),
1299 $database["parsed_url"] = array(
1301 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1302 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1303 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1304 "content" => array("type" => "mediumtext"),
1305 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1308 "PRIMARY" => array("url", "guessing", "oembed"),
1309 "created" => array("created"),
1312 $database["pconfig"] = array(
1314 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1315 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1316 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1317 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1318 "v" => array("type" => "mediumtext"),
1321 "PRIMARY" => array("id"),
1322 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1325 $database["photo"] = array(
1327 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1328 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1329 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1330 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1331 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1332 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1333 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1334 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1335 "desc" => array("type" => "text"),
1336 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1337 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1338 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1339 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1340 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1341 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1342 "data" => array("type" => "mediumblob", "not null" => "1"),
1343 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1344 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1345 "allow_cid" => array("type" => "mediumtext"),
1346 "allow_gid" => array("type" => "mediumtext"),
1347 "deny_cid" => array("type" => "mediumtext"),
1348 "deny_gid" => array("type" => "mediumtext"),
1351 "PRIMARY" => array("id"),
1352 "uid_contactid" => array("uid", "contact-id"),
1353 "uid_profile" => array("uid", "profile"),
1354 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1355 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1356 "resource-id" => array("resource-id(64)"),
1359 $database["poll"] = array(
1361 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1362 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1363 "q0" => array("type" => "text"),
1364 "q1" => array("type" => "text"),
1365 "q2" => array("type" => "text"),
1366 "q3" => array("type" => "text"),
1367 "q4" => array("type" => "text"),
1368 "q5" => array("type" => "text"),
1369 "q6" => array("type" => "text"),
1370 "q7" => array("type" => "text"),
1371 "q8" => array("type" => "text"),
1372 "q9" => array("type" => "text"),
1375 "PRIMARY" => array("id"),
1376 "uid" => array("uid"),
1379 $database["poll_result"] = array(
1381 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1382 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1383 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1386 "PRIMARY" => array("id"),
1387 "poll_id" => array("poll_id"),
1388 "choice" => array("choice"),
1391 $database["process"] = array(
1393 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1394 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1395 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1398 "PRIMARY" => array("pid"),
1399 "command" => array("command"),
1402 $database["profile"] = array(
1404 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1405 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1406 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1407 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1408 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1409 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1410 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1411 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1412 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1413 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1414 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1415 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1416 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1417 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1418 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1419 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1420 "with" => array("type" => "text"),
1421 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1422 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1423 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1424 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1425 "pub_keywords" => array("type" => "text"),
1426 "prv_keywords" => array("type" => "text"),
1427 "likes" => array("type" => "text"),
1428 "dislikes" => array("type" => "text"),
1429 "about" => array("type" => "text"),
1430 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1431 "music" => array("type" => "text"),
1432 "book" => array("type" => "text"),
1433 "tv" => array("type" => "text"),
1434 "film" => array("type" => "text"),
1435 "interest" => array("type" => "text"),
1436 "romance" => array("type" => "text"),
1437 "work" => array("type" => "text"),
1438 "education" => array("type" => "text"),
1439 "contact" => array("type" => "text"),
1440 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1441 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1442 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1443 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1444 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1445 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1448 "PRIMARY" => array("id"),
1449 "uid_is-default" => array("uid", "is-default"),
1452 $database["profile_check"] = array(
1454 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1455 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1456 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1457 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1458 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1459 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1462 "PRIMARY" => array("id"),
1465 $database["push_subscriber"] = array(
1467 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1468 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1469 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1470 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1471 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1472 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1473 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1474 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1477 "PRIMARY" => array("id"),
1480 $database["queue"] = array(
1482 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1483 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1484 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1485 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1486 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1487 "content" => array("type" => "mediumtext"),
1488 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1491 "PRIMARY" => array("id"),
1492 "cid" => array("cid"),
1493 "created" => array("created"),
1494 "last" => array("last"),
1495 "network" => array("network"),
1496 "batch" => array("batch"),
1499 $database["register"] = array(
1501 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1502 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1503 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1504 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1505 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1506 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1507 "note" => array("type" => "text"),
1510 "PRIMARY" => array("id"),
1513 $database["search"] = array(
1515 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1516 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1517 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1520 "PRIMARY" => array("id"),
1521 "uid" => array("uid"),
1524 $database["session"] = array(
1526 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1527 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1528 "data" => array("type" => "text"),
1529 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1532 "PRIMARY" => array("id"),
1533 "sid" => array("sid(64)"),
1534 "expire" => array("expire"),
1537 $database["sign"] = array(
1539 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1540 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1541 "signed_text" => array("type" => "mediumtext"),
1542 "signature" => array("type" => "text"),
1543 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1546 "PRIMARY" => array("id"),
1547 "iid" => array("iid"),
1550 $database["spam"] = array(
1552 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1553 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1554 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1555 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1556 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1557 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1560 "PRIMARY" => array("id"),
1561 "uid" => array("uid"),
1562 "spam" => array("spam"),
1563 "ham" => array("ham"),
1564 "term" => array("term"),
1567 $database["term"] = array(
1569 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1570 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1571 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1572 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1573 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1574 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1575 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1576 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1577 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1578 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1579 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1580 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1583 "PRIMARY" => array("tid"),
1584 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1585 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1586 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1587 "guid" => array("guid(64)"),
1590 $database["thread"] = array(
1592 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1593 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1594 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1595 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1596 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1597 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1598 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1599 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1600 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1601 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1602 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1603 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1604 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1605 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1606 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1607 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1608 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1609 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1610 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1611 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1612 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1613 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1614 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1615 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1616 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1617 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1620 "PRIMARY" => array("iid"),
1621 "uid_network_commented" => array("uid","network","commented"),
1622 "uid_network_created" => array("uid","network","created"),
1623 "uid_contactid_commented" => array("uid","contact-id","commented"),
1624 "uid_contactid_created" => array("uid","contact-id","created"),
1625 "uid_created" => array("uid","created"),
1626 "uid_commented" => array("uid","commented"),
1627 "uid_wall_created" => array("uid","wall","created"),
1630 $database["tokens"] = array(
1632 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1633 "secret" => array("type" => "text"),
1634 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1635 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1636 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1637 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1640 "PRIMARY" => array("id"),
1643 $database["user"] = array(
1645 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1646 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1647 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1648 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1649 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1650 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1651 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1652 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1653 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1654 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1655 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1656 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1657 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1658 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1659 "pubkey" => array("type" => "text"),
1660 "prvkey" => array("type" => "text"),
1661 "spubkey" => array("type" => "text"),
1662 "sprvkey" => array("type" => "text"),
1663 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1664 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1665 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1666 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1667 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1668 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1669 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1670 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1671 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1672 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1673 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1674 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1675 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1676 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1677 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1678 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1679 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1680 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1681 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1682 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1683 "allow_cid" => array("type" => "mediumtext"),
1684 "allow_gid" => array("type" => "mediumtext"),
1685 "deny_cid" => array("type" => "mediumtext"),
1686 "deny_gid" => array("type" => "mediumtext"),
1687 "openidserver" => array("type" => "text"),
1690 "PRIMARY" => array("uid"),
1691 "nickname" => array("nickname(32)"),
1694 $database["userd"] = array(
1696 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1697 "username" => array("type" => "varchar(255)", "not null" => "1"),
1700 "PRIMARY" => array("id"),
1701 "username" => array("username(32)"),
1704 $database["workerqueue"] = array(
1706 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1707 "parameter" => array("type" => "text"),
1708 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1709 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1710 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1711 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1714 "PRIMARY" => array("id"),
1723 * run from command line
1725 function dbstructure_run(&$argv, &$argc) {
1733 @include(".htconfig.php");
1734 require_once("include/dba.php");
1735 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1736 unset($db_host, $db_user, $db_pass, $db_data);
1742 update_structure(true, false);
1745 update_structure(true, true);
1747 $build = get_config('system','build');
1749 set_config('system','build',DB_UPDATE_VERSION);
1750 $build = DB_UPDATE_VERSION;
1753 $stored = intval($build);
1754 $current = intval(DB_UPDATE_VERSION);
1756 // run any left update_nnnn functions in update.php
1757 for ($x = $stored; $x < $current; $x ++) {
1758 $r = run_update_function($x);
1762 set_config('system','build',DB_UPDATE_VERSION);
1765 print_structure(db_definition());
1768 convert_to_innodb();
1775 echo $argv[0]." <command>\n";
1778 echo "dryrun show database update schema queries without running them\n";
1779 echo "update update database schema\n";
1780 echo "dumpsql dump database schema\n";
1781 echo "toinnodb convert all tables from MyISAM to InnoDB\n";
1786 if (array_search(__file__,get_included_files())===0) {
1787 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);