3 use \Friendica\Core\Config;
5 require_once("boot.php");
6 require_once("include/text.php");
8 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
11 * send the email and do what is needed to do on update fails
13 * @param update_id (int) number of failed update
14 * @param error_message (str) error message
16 function update_fail($update_id, $error_message){
17 //send the administrators an e-mail
18 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
19 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
24 if (!dbm::is_result($adminlist)) {
25 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
31 // every admin could had different language
32 foreach ($adminlist as $admin) {
33 $lang = (($admin['language'])?$admin['language']:'en');
36 $preamble = deindent(t("
37 The friendica developers released update %s recently,
38 but when I tried to install it, something went terribly wrong.
39 This needs to be fixed soon and I can't do it alone. Please contact a
40 friendica developer if you can not help me on your own. My database might be invalid."));
41 $body = t("The error message is\n[pre]%s[/pre]");
42 $preamble = sprintf($preamble, $update_id);
43 $body = sprintf($body, $error_message);
46 'type' => "SYSTEM_EMAIL",
47 'to_email' => $admin['email'],
48 'preamble' => $preamble,
58 $email_tpl = get_intltext_template("update_fail_eml.tpl");
59 $email_msg = replace_macros($email_tpl, array(
60 '$sitename' => $a->config['sitename'],
61 '$siteurl' => App::get_baseurl(),
62 '$update' => DB_UPDATE_VERSION,
63 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
65 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
66 require_once('include/email.php');
67 $subject = email_header_encode($subject,'UTF-8');
68 mail($a->config['admin_email'], $subject, $email_msg,
69 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
70 .'Content-type: text/plain; charset=UTF-8'."\n"
71 .'Content-transfer-encoding: 8bit');
74 logger("CRITICAL: Database structure update failed: ".$retval);
78 function table_structure($table) {
79 $structures = q("DESCRIBE `%s`", $table);
81 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
83 $indexes = q("SHOW INDEX FROM `%s`", $table);
85 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
87 if (dbm::is_result($table_status)) {
88 $table_status = $table_status[0];
90 $table_status = array();
96 if (dbm::is_result($indexes))
97 foreach ($indexes AS $index) {
98 if ($index["Index_type"] == "FULLTEXT") {
102 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
103 $indexdata[$index["Key_name"]] = array('UNIQUE');
106 $column = $index["Column_name"];
107 // On utf8mb4 a varchar index can only have a length of 191
108 // To avoid the need to add this to every index definition we just ignore it here.
109 // Exception are primary indexes
110 // Since there are some combindex primary indexes we use the limit of 180 here.
111 if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) {
112 $column .= "(".$index["Sub_part"].")";
115 $indexdata[$index["Key_name"]][] = $column;
117 if (dbm::is_result($structures)) {
118 foreach ($structures AS $field) {
119 $fielddata[$field["Field"]]["type"] = $field["Type"];
120 if ($field["Null"] == "NO") {
121 $fielddata[$field["Field"]]["not null"] = true;
124 if (isset($field["Default"])) {
125 $fielddata[$field["Field"]]["default"] = $field["Default"];
128 if ($field["Extra"] != "") {
129 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
132 if ($field["Key"] == "PRI") {
133 $fielddata[$field["Field"]]["primary"] = true;
137 if (dbm::is_result($full_columns)) {
138 foreach ($full_columns AS $column) {
139 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
143 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
146 function print_structure($database) {
147 echo "-- ------------------------------------------\n";
148 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
149 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
150 echo "-- ------------------------------------------\n\n\n";
151 foreach ($database AS $name => $structure) {
153 echo "-- TABLE $name\n";
155 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
162 * @brief Print out database error messages
164 * @param object $db Database object
165 * @param string $message Message to be added to the error message
167 * @return string Error message
169 function print_update_error($db, $message) {
170 echo sprintf(t("\nError %d occured during database update:\n%s\n"),
171 $db->errorno, $db->error);
173 return t('Errors encountered performing database changes: ').$message.EOL;
176 function update_structure($verbose, $action, $tables=null, $definition=null) {
180 Config::set('system', 'maintenance', 1);
181 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
186 logger('updating structure', LOGGER_DEBUG);
188 // Get the current structure
191 if (is_null($tables)) {
192 $tables = q("SHOW TABLES");
195 if (dbm::is_result($tables)) {
196 foreach ($tables AS $table) {
197 $table = current($table);
199 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
200 $database[$table] = table_structure($table);
204 // Get the definition
205 if (is_null($definition)) {
206 $definition = db_definition();
209 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
210 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
211 !(strpos($db->server_info(), 'MariaDB') !== false)) {
218 foreach ($definition AS $name => $structure) {
219 $is_new_table = False;
222 if (!isset($database[$name])) {
223 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
224 if (!dbm::is_result($r)) {
225 $errors .= print_update_error($db, $name);
227 $is_new_table = True;
232 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
233 if (isset($database[$name]["indexes"][$indexname])) {
234 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
236 $current_index_definition = "__NOT_SET__";
238 $new_index_definition = implode(",",$fieldnames);
239 if ($current_index_definition != $new_index_definition) {
240 if ($fieldnames[0] == "UNIQUE") {
243 $temp_name = "temp-".$name;
250 * Drop the index if it isn't present in the definition
251 * or the definition differ from current status
252 * and index name doesn't start with "local_"
254 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
255 $current_index_definition = implode(",",$fieldnames);
256 if (isset($structure["indexes"][$indexname])) {
257 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
259 $new_index_definition = "__NOT_SET__";
261 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
262 $sql2=db_drop_index($indexname);
264 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
270 // Compare the field structure field by field
271 foreach ($structure["fields"] AS $fieldname => $parameters) {
272 if (!isset($database[$name]["fields"][$fieldname])) {
273 $sql2=db_add_table_field($fieldname, $parameters);
275 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
280 // Compare the field definition
281 $field_definition = $database[$name]["fields"][$fieldname];
283 // We change the collation after the indexes had been changed.
284 // This is done to avoid index length problems.
285 // So here we always ensure that there is no need to change it.
286 unset($parameters['Collation']);
287 unset($field_definition['Collation']);
289 $current_field_definition = implode(",", $field_definition);
290 $new_field_definition = implode(",", $parameters);
291 if ($current_field_definition != $new_field_definition) {
292 $sql2 = db_modify_table_field($fieldname, $parameters);
294 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
304 * Create the index if the index don't exists in database
305 * or the definition differ from the current status.
306 * Don't create keys if table is new
308 if (!$is_new_table) {
309 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
310 if (isset($database[$name]["indexes"][$indexname])) {
311 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
313 $current_index_definition = "__NOT_SET__";
315 $new_index_definition = implode(",",$fieldnames);
316 if ($current_index_definition != $new_index_definition) {
317 $sql2 = db_create_index($indexname, $fieldnames);
319 // Fetch the "group by" fields for unique indexes
320 if ($fieldnames[0] == "UNIQUE") {
321 $group_by = db_group_by($indexname, $fieldnames);
325 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
333 if (isset($database[$name]["table_status"]["Collation"])) {
334 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
335 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
338 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
349 // Now have a look at the field collations
350 // Compare the field structure field by field
351 foreach ($structure["fields"] AS $fieldname => $parameters) {
352 // Compare the field definition
353 $field_definition = $database[$name]["fields"][$fieldname];
355 // Define the default collation if not given
356 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
357 $parameters['Collation'] = 'utf8mb4_general_ci';
359 $parameters['Collation'] = null;
362 if ($field_definition['Collation'] != $parameters['Collation']) {
363 $sql2 = db_modify_table_field($fieldname, $parameters);
364 if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
365 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
374 if (substr($sql3, -2, 2) != "; ") {
379 // Ensure index conversion to unique removes duplicates
382 echo "SET session old_alter_table=1;\n";
384 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
392 echo "SET session old_alter_table=0;\n";
394 echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
395 echo "DROP TABLE `".$name."`;\n";
396 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
402 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
404 // Ensure index conversion to unique removes duplicates
407 $db->q("SET session old_alter_table=1;");
409 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
410 if (!dbm::is_result($r)) {
411 $errors .= print_update_error($db, $sql3);
418 if (!dbm::is_result($r)) {
419 $errors .= print_update_error($db, $sql3);
423 $db->q("SET session old_alter_table=0;");
425 $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
426 if (!dbm::is_result($r)) {
427 $errors .= print_update_error($db, $sql3);
430 $r = $db->q("DROP TABLE `".$name."`;");
431 if (!dbm::is_result($r)) {
432 $errors .= print_update_error($db, $sql3);
435 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
436 if (!dbm::is_result($r)) {
437 $errors .= print_update_error($db, $sql3);
447 Config::set('system', 'maintenance', 0);
448 Config::set('system', 'maintenance_reason', '');
454 function db_field_command($parameters, $create = true) {
455 $fieldstruct = $parameters["type"];
457 if (!is_null($parameters["Collation"])) {
458 $fieldstruct .= " COLLATE ".$parameters["Collation"];
461 if ($parameters["not null"])
462 $fieldstruct .= " NOT NULL";
464 if (isset($parameters["default"])){
465 if (strpos(strtolower($parameters["type"]),"int")!==false) {
466 $fieldstruct .= " DEFAULT ".$parameters["default"];
468 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
471 if ($parameters["extra"] != "")
472 $fieldstruct .= " ".$parameters["extra"];
474 /*if (($parameters["primary"] != "") AND $create)
475 $fieldstruct .= " PRIMARY KEY";*/
477 return($fieldstruct);
480 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
488 $primary_keys = array();
489 foreach ($fields AS $fieldname => $field) {
490 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
491 if (x($field,'primary') and $field['primary']!=''){
492 $primary_keys[] = $fieldname;
496 if (!is_null($indexes)) {
497 foreach ($indexes AS $indexname => $fieldnames) {
498 $sql_index = db_create_index($indexname, $fieldnames, "");
499 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
503 $sql = implode(",\n\t", $sql_rows);
505 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
515 function db_add_table_field($fieldname, $parameters) {
516 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
520 function db_modify_table_field($fieldname, $parameters) {
521 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
525 function db_drop_index($indexname) {
526 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
530 function db_create_index($indexname, $fieldnames, $method="ADD") {
532 $method = strtoupper(trim($method));
533 if ($method!="" && $method!="ADD") {
534 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
538 if ($fieldnames[0] == "UNIQUE") {
539 array_shift($fieldnames);
540 $method .= ' UNIQUE';
544 foreach ($fieldnames AS $fieldname) {
548 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
549 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
551 $names .= "`".dbesc($fieldname)."`";
555 if ($indexname == "PRIMARY") {
556 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
560 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
564 function db_group_by($indexname, $fieldnames) {
566 if ($fieldnames[0] != "UNIQUE") {
570 array_shift($fieldnames);
573 foreach ($fieldnames AS $fieldname) {
577 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
578 $names .= "`".dbesc($matches[1])."`";
580 $names .= "`".dbesc($fieldname)."`";
584 $sql = sprintf(" GROUP BY %s", $names);
588 function db_definition() {
592 $database["addon"] = array(
594 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
595 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
596 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
597 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
598 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
599 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
600 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
603 "PRIMARY" => array("id"),
604 "name" => array("UNIQUE", "name"),
607 $database["attach"] = array(
609 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
610 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
611 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
612 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
613 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
614 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
615 "data" => array("type" => "longblob", "not null" => "1"),
616 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
617 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
618 "allow_cid" => array("type" => "mediumtext"),
619 "allow_gid" => array("type" => "mediumtext"),
620 "deny_cid" => array("type" => "mediumtext"),
621 "deny_gid" => array("type" => "mediumtext"),
624 "PRIMARY" => array("id"),
627 $database["auth_codes"] = array(
629 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
630 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
631 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
632 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
633 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
636 "PRIMARY" => array("id"),
639 $database["cache"] = array(
641 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
642 "v" => array("type" => "mediumtext"),
643 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
644 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
647 "PRIMARY" => array("k"),
648 "expire_mode_updated" => array("expire_mode", "updated"),
651 $database["challenge"] = array(
653 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
654 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
655 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
656 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
657 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
658 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
661 "PRIMARY" => array("id"),
664 $database["clients"] = array(
666 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
667 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
668 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
669 "name" => array("type" => "text"),
670 "icon" => array("type" => "text"),
671 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
674 "PRIMARY" => array("client_id"),
677 $database["config"] = array(
679 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
680 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
681 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
682 "v" => array("type" => "mediumtext"),
685 "PRIMARY" => array("id"),
686 "cat_k" => array("UNIQUE", "cat", "k"),
689 $database["contact"] = array(
691 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
692 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
693 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
694 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
695 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
696 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
697 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
698 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
700 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
701 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
702 "about" => array("type" => "text"),
703 "keywords" => array("type" => "text"),
704 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
705 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
706 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
707 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
708 "photo" => array("type" => "text"),
709 "thumb" => array("type" => "text"),
710 "micro" => array("type" => "text"),
711 "site-pubkey" => array("type" => "text"),
712 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
713 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
714 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
715 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
716 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
717 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
718 "pubkey" => array("type" => "text"),
719 "prvkey" => array("type" => "text"),
720 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
721 "request" => array("type" => "text"),
722 "notify" => array("type" => "text"),
723 "poll" => array("type" => "text"),
724 "confirm" => array("type" => "text"),
725 "poco" => array("type" => "text"),
726 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
727 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
728 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
729 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
730 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
732 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
733 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
734 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
735 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
736 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
737 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
738 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
739 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
740 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
741 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
742 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
743 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
744 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
745 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
746 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
747 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
748 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
749 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
750 "reason" => array("type" => "text"),
751 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
752 "info" => array("type" => "mediumtext"),
753 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
754 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
755 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
756 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
757 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
758 "ffi_keyword_blacklist" => array("type" => "text"),
761 "PRIMARY" => array("id"),
762 "uid_name" => array("uid", "name"),
763 "self_uid" => array("self", "uid"),
764 "alias_uid" => array("alias(32)", "uid"),
765 "pending_uid" => array("pending", "uid"),
766 "blocked_uid" => array("blocked", "uid"),
767 "uid_rel_network_poll" => array("uid", "rel", "network", "poll(64)", "archive"),
768 "uid_network_batch" => array("uid", "network", "batch(64)"),
769 "addr_uid" => array("addr(32)", "uid"),
770 "nurl_uid" => array("nurl(32)", "uid"),
771 "nick_uid" => array("nick(32)", "uid"),
772 "dfrn-id" => array("dfrn-id"),
773 "issued-id" => array("issued-id"),
776 $database["conv"] = array(
778 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
779 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
780 "recips" => array("type" => "text"),
781 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
782 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
783 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
784 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
785 "subject" => array("type" => "text"),
788 "PRIMARY" => array("id"),
789 "uid" => array("uid"),
792 $database["event"] = array(
794 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
795 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
796 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
797 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
798 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
799 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
800 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
801 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
802 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
803 "summary" => array("type" => "text"),
804 "desc" => array("type" => "text"),
805 "location" => array("type" => "text"),
806 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
807 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
808 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
809 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
810 "allow_cid" => array("type" => "mediumtext"),
811 "allow_gid" => array("type" => "mediumtext"),
812 "deny_cid" => array("type" => "mediumtext"),
813 "deny_gid" => array("type" => "mediumtext"),
816 "PRIMARY" => array("id"),
817 "uid_start" => array("uid", "start"),
820 $database["fcontact"] = array(
822 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
823 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
824 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
825 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
826 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
827 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
828 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
829 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
830 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
831 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
832 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
833 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
834 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
835 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
836 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
837 "pubkey" => array("type" => "text"),
838 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
841 "PRIMARY" => array("id"),
842 "addr" => array("addr(32)"),
843 "url" => array("url"),
846 $database["ffinder"] = array(
848 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
849 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
850 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
851 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
854 "PRIMARY" => array("id"),
857 $database["fserver"] = array(
859 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
860 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
861 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
862 "key" => array("type" => "text"),
865 "PRIMARY" => array("id"),
866 "server" => array("server(32)"),
869 $database["fsuggest"] = array(
871 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
872 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
873 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
874 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
875 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
877 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
878 "note" => array("type" => "text"),
879 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
882 "PRIMARY" => array("id"),
885 $database["gcign"] = array(
887 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
888 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
889 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
892 "PRIMARY" => array("id"),
893 "uid" => array("uid"),
894 "gcid" => array("gcid"),
897 $database["gcontact"] = array(
899 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
900 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
902 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
903 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
904 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
905 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
906 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
907 "updated" => array("type" => "datetime", "default" => NULL_DATE),
908 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
909 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
910 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
911 "about" => array("type" => "text"),
912 "keywords" => array("type" => "text"),
913 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
914 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
915 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
916 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
917 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
918 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
919 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
920 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
921 "notify" => array("type" => "text"),
922 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
923 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
924 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
927 "PRIMARY" => array("id"),
928 "nurl" => array("nurl(64)"),
929 "name" => array("name(64)"),
930 "nick" => array("nick(32)"),
931 "addr" => array("addr(64)"),
932 "hide_network_updated" => array("hide", "network", "updated"),
933 "updated" => array("updated"),
936 $database["glink"] = array(
938 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
939 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
940 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
941 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
942 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
943 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
946 "PRIMARY" => array("id"),
947 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
948 "gcid" => array("gcid"),
951 $database["group"] = array(
953 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
954 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
955 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
956 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
957 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "PRIMARY" => array("id"),
961 "uid" => array("uid"),
964 $database["group_member"] = array(
966 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
967 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
968 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
969 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
972 "PRIMARY" => array("id"),
973 "contactid" => array("contact-id"),
974 "gid_contactid" => array("gid", "contact-id"),
975 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
978 $database["gserver"] = array(
980 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
981 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
982 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
983 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
984 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
985 "info" => array("type" => "text"),
986 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
987 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
988 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
989 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
990 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
991 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
992 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
993 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
994 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
997 "PRIMARY" => array("id"),
998 "nurl" => array("nurl(32)"),
1001 $database["hook"] = array(
1003 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1004 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1005 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1006 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1007 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1010 "PRIMARY" => array("id"),
1011 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1014 $database["intro"] = 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"),
1018 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1019 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1020 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1021 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1022 "note" => array("type" => "text"),
1023 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1024 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1025 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1026 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1029 "PRIMARY" => array("id"),
1032 $database["item"] = array(
1034 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1035 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1036 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1037 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1038 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1039 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1040 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1042 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1043 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1044 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1048 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1049 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1050 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1051 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1052 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1053 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1054 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1055 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1056 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1057 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1058 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1059 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1060 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1061 "body" => array("type" => "mediumtext"),
1062 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1063 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1064 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1065 "object" => array("type" => "text"),
1066 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1067 "target" => array("type" => "text"),
1068 "postopts" => array("type" => "text"),
1069 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1070 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1071 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1072 "tag" => array("type" => "mediumtext"),
1073 "attach" => array("type" => "mediumtext"),
1074 "inform" => array("type" => "mediumtext"),
1075 "file" => array("type" => "mediumtext"),
1076 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1077 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1078 "allow_cid" => array("type" => "mediumtext"),
1079 "allow_gid" => array("type" => "mediumtext"),
1080 "deny_cid" => array("type" => "mediumtext"),
1081 "deny_gid" => array("type" => "mediumtext"),
1082 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1083 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1084 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1085 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1086 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1087 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1088 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1089 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1090 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1091 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1092 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1093 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1094 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1095 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1096 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1097 "rendered-html" => array("type" => "mediumtext"),
1098 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1101 "PRIMARY" => array("id"),
1102 "guid" => array("guid"),
1103 "uri" => array("uri"),
1104 "parent" => array("parent"),
1105 "parent-uri" => array("parent-uri"),
1106 "extid" => array("extid"),
1107 "uid_id" => array("uid","id"),
1108 "uid_contactid_id" => array("uid","contact-id","id"),
1109 "uid_created" => array("uid","created"),
1110 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1111 "uid_network_received" => array("uid","network","received"),
1112 "uid_network_commented" => array("uid","network","commented"),
1113 "uid_thrparent" => array("uid","thr-parent"),
1114 "uid_parenturi" => array("uid","parent-uri"),
1115 "uid_contactid_created" => array("uid","contact-id","created"),
1116 "authorid_created" => array("author-id","created"),
1117 "uid_uri" => array("uid", "uri"),
1118 "resource-id" => array("resource-id"),
1119 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1120 "uid_type_changed" => array("uid","type","changed"),
1121 "contactid_verb" => array("contact-id","verb"),
1122 "deleted_changed" => array("deleted","changed"),
1123 "uid_wall_changed" => array("uid","wall","changed"),
1124 "uid_eventid" => array("uid","event-id"),
1125 "uid_authorlink" => array("uid","author-link"),
1126 "uid_ownerlink" => array("uid","owner-link"),
1129 $database["item_id"] = array(
1131 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1132 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1133 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1134 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1135 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1138 "PRIMARY" => array("id"),
1139 "uid" => array("uid"),
1140 "sid" => array("sid"),
1141 "service" => array("service(32)"),
1142 "iid" => array("iid"),
1145 $database["locks"] = array(
1147 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1148 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1149 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1150 "created" => array("type" => "datetime", "default" => NULL_DATE),
1153 "PRIMARY" => array("id"),
1156 $database["mail"] = array(
1158 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1159 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1160 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1161 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1162 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1163 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1164 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1165 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1166 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1167 "body" => array("type" => "mediumtext"),
1168 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1169 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1170 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1171 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1172 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1173 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1174 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1177 "PRIMARY" => array("id"),
1178 "uid_seen" => array("uid", "seen"),
1179 "convid" => array("convid"),
1180 "uri" => array("uri(64)"),
1181 "parent-uri" => array("parent-uri(64)"),
1184 $database["mailacct"] = array(
1186 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1187 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1188 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1189 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1190 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1191 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1192 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1193 "pass" => array("type" => "text"),
1194 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1195 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1196 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1197 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1198 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1201 "PRIMARY" => array("id"),
1204 $database["manage"] = array(
1206 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1207 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1208 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1211 "PRIMARY" => array("id"),
1212 "uid_mid" => array("UNIQUE", "uid","mid"),
1215 $database["notify"] = array(
1217 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1218 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1219 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1220 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1221 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1222 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1223 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1224 "msg" => array("type" => "mediumtext"),
1225 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1226 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1227 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1228 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1229 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1230 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1231 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1232 "name_cache" => array("type" => "tinytext"),
1233 "msg_cache" => array("type" => "mediumtext")
1236 "PRIMARY" => array("id"),
1237 "hash_uid" => array("hash", "uid"),
1238 "seen_uid_date" => array("seen", "uid", "date"),
1239 "uid_date" => array("uid", "date"),
1240 "uid_type_link" => array("uid", "type", "link"),
1243 $database["notify-threads"] = array(
1245 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1246 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1247 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1248 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1249 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1252 "PRIMARY" => array("id"),
1255 $database["oembed"] = array(
1257 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1258 "content" => array("type" => "mediumtext"),
1259 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1262 "PRIMARY" => array("url"),
1263 "created" => array("created"),
1266 $database["parsed_url"] = array(
1268 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1269 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1270 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1271 "content" => array("type" => "mediumtext"),
1272 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1275 "PRIMARY" => array("url", "guessing", "oembed"),
1276 "created" => array("created"),
1279 $database["pconfig"] = array(
1281 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1282 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1283 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1284 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1285 "v" => array("type" => "mediumtext"),
1288 "PRIMARY" => array("id"),
1289 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1292 $database["photo"] = array(
1294 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1295 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1296 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1297 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1298 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1299 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1300 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1301 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1302 "desc" => array("type" => "text"),
1303 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1304 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1305 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1306 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1307 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1308 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1309 "data" => array("type" => "mediumblob", "not null" => "1"),
1310 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1311 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1312 "allow_cid" => array("type" => "mediumtext"),
1313 "allow_gid" => array("type" => "mediumtext"),
1314 "deny_cid" => array("type" => "mediumtext"),
1315 "deny_gid" => array("type" => "mediumtext"),
1318 "PRIMARY" => array("id"),
1319 "uid_contactid" => array("uid", "contact-id"),
1320 "uid_profile" => array("uid", "profile"),
1321 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1322 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1323 "resource-id" => array("resource-id(64)"),
1326 $database["poll"] = array(
1328 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1329 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1330 "q0" => array("type" => "text"),
1331 "q1" => array("type" => "text"),
1332 "q2" => array("type" => "text"),
1333 "q3" => array("type" => "text"),
1334 "q4" => array("type" => "text"),
1335 "q5" => array("type" => "text"),
1336 "q6" => array("type" => "text"),
1337 "q7" => array("type" => "text"),
1338 "q8" => array("type" => "text"),
1339 "q9" => array("type" => "text"),
1342 "PRIMARY" => array("id"),
1343 "uid" => array("uid"),
1346 $database["poll_result"] = array(
1348 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1349 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1350 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1353 "PRIMARY" => array("id"),
1354 "poll_id" => array("poll_id"),
1355 "choice" => array("choice"),
1358 $database["process"] = array(
1360 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1361 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1362 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1365 "PRIMARY" => array("pid"),
1366 "command" => array("command"),
1369 $database["profile"] = array(
1371 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1372 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1373 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1374 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1375 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1376 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1377 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1378 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1379 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1380 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1381 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1382 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1383 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1384 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1385 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1386 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1387 "with" => array("type" => "text"),
1388 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1389 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1390 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1391 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1392 "pub_keywords" => array("type" => "text"),
1393 "prv_keywords" => array("type" => "text"),
1394 "likes" => array("type" => "text"),
1395 "dislikes" => array("type" => "text"),
1396 "about" => array("type" => "text"),
1397 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1398 "music" => array("type" => "text"),
1399 "book" => array("type" => "text"),
1400 "tv" => array("type" => "text"),
1401 "film" => array("type" => "text"),
1402 "interest" => array("type" => "text"),
1403 "romance" => array("type" => "text"),
1404 "work" => array("type" => "text"),
1405 "education" => array("type" => "text"),
1406 "contact" => array("type" => "text"),
1407 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1408 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1409 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1410 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1411 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1412 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1415 "PRIMARY" => array("id"),
1416 "uid_is-default" => array("uid", "is-default"),
1419 $database["profile_check"] = array(
1421 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1422 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1423 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1424 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1425 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1426 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1429 "PRIMARY" => array("id"),
1432 $database["push_subscriber"] = array(
1434 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1435 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1436 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1437 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1438 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1439 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1440 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1441 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1444 "PRIMARY" => array("id"),
1447 $database["queue"] = array(
1449 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1450 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1451 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1452 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1453 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1454 "content" => array("type" => "mediumtext"),
1455 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1458 "PRIMARY" => array("id"),
1459 "cid" => array("cid"),
1460 "created" => array("created"),
1461 "last" => array("last"),
1462 "network" => array("network"),
1463 "batch" => array("batch"),
1466 $database["register"] = array(
1468 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1469 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1470 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1471 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1472 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1473 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1474 "note" => array("type" => "text"),
1477 "PRIMARY" => array("id"),
1480 $database["search"] = array(
1482 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1483 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1484 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1487 "PRIMARY" => array("id"),
1488 "uid" => array("uid"),
1491 $database["session"] = array(
1493 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1494 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1495 "data" => array("type" => "text"),
1496 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1499 "PRIMARY" => array("id"),
1500 "sid" => array("sid(64)"),
1501 "expire" => array("expire"),
1504 $database["sign"] = array(
1506 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1507 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1508 "signed_text" => array("type" => "mediumtext"),
1509 "signature" => array("type" => "text"),
1510 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1513 "PRIMARY" => array("id"),
1514 "iid" => array("iid"),
1517 $database["spam"] = array(
1519 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1520 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1521 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1522 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1523 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1524 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1527 "PRIMARY" => array("id"),
1528 "uid" => array("uid"),
1529 "spam" => array("spam"),
1530 "ham" => array("ham"),
1531 "term" => array("term"),
1534 $database["term"] = array(
1536 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1537 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1538 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1539 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1540 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1541 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1542 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1543 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1544 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1545 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1546 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1547 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1550 "PRIMARY" => array("tid"),
1551 "oid_otype_type_term" => array("oid","otype","type","term"),
1552 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1553 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1554 "guid" => array("guid(64)"),
1557 $database["thread"] = array(
1559 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1560 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1561 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1562 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1563 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1564 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1565 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1566 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1567 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1568 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1569 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1570 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1571 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1572 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1573 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1574 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1575 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1576 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1577 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1578 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1579 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1580 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1581 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1582 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1583 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1584 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1587 "PRIMARY" => array("iid"),
1588 "uid_network_commented" => array("uid","network","commented"),
1589 "uid_network_created" => array("uid","network","created"),
1590 "uid_contactid_commented" => array("uid","contact-id","commented"),
1591 "uid_contactid_created" => array("uid","contact-id","created"),
1592 "uid_created" => array("uid","created"),
1593 "uid_commented" => array("uid","commented"),
1594 "uid_wall_created" => array("uid","wall","created"),
1597 $database["tokens"] = array(
1599 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1600 "secret" => array("type" => "text"),
1601 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1602 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1603 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1604 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1607 "PRIMARY" => array("id"),
1610 $database["user"] = array(
1612 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1613 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1614 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1615 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1616 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1617 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1618 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1619 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1620 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1621 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1622 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1623 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1624 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1625 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1626 "pubkey" => array("type" => "text"),
1627 "prvkey" => array("type" => "text"),
1628 "spubkey" => array("type" => "text"),
1629 "sprvkey" => array("type" => "text"),
1630 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1631 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1632 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1633 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1634 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1635 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1636 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1637 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1638 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1639 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1640 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1641 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1642 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1643 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1644 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1645 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1646 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1647 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1648 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1649 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1650 "allow_cid" => array("type" => "mediumtext"),
1651 "allow_gid" => array("type" => "mediumtext"),
1652 "deny_cid" => array("type" => "mediumtext"),
1653 "deny_gid" => array("type" => "mediumtext"),
1654 "openidserver" => array("type" => "text"),
1657 "PRIMARY" => array("uid"),
1658 "nickname" => array("nickname(32)"),
1661 $database["userd"] = array(
1663 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1664 "username" => array("type" => "varchar(255)", "not null" => "1"),
1667 "PRIMARY" => array("id"),
1668 "username" => array("username(32)"),
1671 $database["workerqueue"] = array(
1673 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1674 "parameter" => array("type" => "text"),
1675 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1676 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1677 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1678 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1681 "PRIMARY" => array("id"),
1690 * run from command line
1692 function dbstructure_run(&$argv, &$argc) {
1700 @include(".htconfig.php");
1701 require_once("include/dba.php");
1702 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1703 unset($db_host, $db_user, $db_pass, $db_data);
1709 update_structure(true, false);
1712 update_structure(true, true);
1714 $build = get_config('system','build');
1716 set_config('system','build',DB_UPDATE_VERSION);
1717 $build = DB_UPDATE_VERSION;
1720 $stored = intval($build);
1721 $current = intval(DB_UPDATE_VERSION);
1723 // run any left update_nnnn functions in update.php
1724 for ($x = $stored; $x < $current; $x ++) {
1725 $r = run_update_function($x);
1729 set_config('system','build',DB_UPDATE_VERSION);
1732 print_structure(db_definition());
1739 echo $argv[0]." <command>\n";
1742 echo "dryrun show database update schema queries without running them\n";
1743 echo "update update database schema\n";
1744 echo "dumpsql dump database schema\n";
1749 if (array_search(__file__,get_included_files())===0){
1750 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);