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 // The "show index" command sometimes returns this value although this value wasn't added manually.
109 // Because we don't want to add this number to every index, we ignore bigger numbers
110 if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 191) OR ($index["Key_name"] == "PRIMARY"))) {
111 $column .= "(".$index["Sub_part"].")";
114 $indexdata[$index["Key_name"]][] = $column;
116 if (dbm::is_result($structures)) {
117 foreach ($structures AS $field) {
118 $fielddata[$field["Field"]]["type"] = $field["Type"];
119 if ($field["Null"] == "NO") {
120 $fielddata[$field["Field"]]["not null"] = true;
123 if (isset($field["Default"])) {
124 $fielddata[$field["Field"]]["default"] = $field["Default"];
127 if ($field["Extra"] != "") {
128 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
131 if ($field["Key"] == "PRI") {
132 $fielddata[$field["Field"]]["primary"] = true;
136 if (dbm::is_result($full_columns)) {
137 foreach ($full_columns AS $column) {
138 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
142 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
145 function print_structure($database) {
146 echo "-- ------------------------------------------\n";
147 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
148 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
149 echo "-- ------------------------------------------\n\n\n";
150 foreach ($database AS $name => $structure) {
152 echo "-- TABLE $name\n";
154 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
161 * @brief Print out database error messages
163 * @param object $db Database object
164 * @param string $message Message to be added to the error message
166 * @return string Error message
168 function print_update_error($db, $message) {
169 echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
170 $db->errorno, $db->error);
172 return t('Errors encountered performing database changes: ').$message.EOL;
175 function update_structure($verbose, $action, $tables=null, $definition=null) {
179 Config::set('system', 'maintenance', 1);
180 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
185 logger('updating structure', LOGGER_DEBUG);
187 // Get the current structure
190 if (is_null($tables)) {
191 $tables = q("SHOW TABLES");
194 if (dbm::is_result($tables)) {
195 foreach ($tables AS $table) {
196 $table = current($table);
198 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
199 $database[$table] = table_structure($table);
203 // Get the definition
204 if (is_null($definition)) {
205 $definition = db_definition();
208 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
209 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
210 !(strpos($db->server_info(), 'MariaDB') !== false)) {
217 foreach ($definition AS $name => $structure) {
218 $is_new_table = False;
221 if (!isset($database[$name])) {
222 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
223 if (!dbm::is_result($r)) {
224 $errors .= print_update_error($db, $name);
226 $is_new_table = True;
231 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
232 if (isset($database[$name]["indexes"][$indexname])) {
233 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
235 $current_index_definition = "__NOT_SET__";
237 $new_index_definition = implode(",",$fieldnames);
238 if ($current_index_definition != $new_index_definition) {
239 if ($fieldnames[0] == "UNIQUE") {
242 $temp_name = "temp-".$name;
249 * Drop the index if it isn't present in the definition
250 * or the definition differ from current status
251 * and index name doesn't start with "local_"
253 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
254 $current_index_definition = implode(",",$fieldnames);
255 if (isset($structure["indexes"][$indexname])) {
256 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
258 $new_index_definition = "__NOT_SET__";
260 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
261 $sql2=db_drop_index($indexname);
263 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
269 // Compare the field structure field by field
270 foreach ($structure["fields"] AS $fieldname => $parameters) {
271 if (!isset($database[$name]["fields"][$fieldname])) {
272 $sql2=db_add_table_field($fieldname, $parameters);
274 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
279 // Compare the field definition
280 $field_definition = $database[$name]["fields"][$fieldname];
282 // We change the collation after the indexes had been changed.
283 // This is done to avoid index length problems.
284 // So here we always ensure that there is no need to change it.
285 unset($parameters['Collation']);
286 unset($field_definition['Collation']);
288 $current_field_definition = implode(",", $field_definition);
289 $new_field_definition = implode(",", $parameters);
290 if ($current_field_definition != $new_field_definition) {
291 $sql2 = db_modify_table_field($fieldname, $parameters);
293 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
303 * Create the index if the index don't exists in database
304 * or the definition differ from the current status.
305 * Don't create keys if table is new
307 if (!$is_new_table) {
308 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
309 if (isset($database[$name]["indexes"][$indexname])) {
310 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
312 $current_index_definition = "__NOT_SET__";
314 $new_index_definition = implode(",",$fieldnames);
315 if ($current_index_definition != $new_index_definition) {
316 $sql2 = db_create_index($indexname, $fieldnames);
318 // Fetch the "group by" fields for unique indexes
319 if ($fieldnames[0] == "UNIQUE") {
320 $group_by = db_group_by($indexname, $fieldnames);
324 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
332 if (isset($database[$name]["table_status"]["Collation"])) {
333 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
334 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
337 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
348 // Now have a look at the field collations
349 // Compare the field structure field by field
350 foreach ($structure["fields"] AS $fieldname => $parameters) {
351 // Compare the field definition
352 $field_definition = $database[$name]["fields"][$fieldname];
354 // Define the default collation if not given
355 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
356 $parameters['Collation'] = 'utf8mb4_general_ci';
358 $parameters['Collation'] = null;
361 if ($field_definition['Collation'] != $parameters['Collation']) {
362 $sql2 = db_modify_table_field($fieldname, $parameters);
363 if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
364 $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
373 if (substr($sql3, -2, 2) != "; ") {
378 // Ensure index conversion to unique removes duplicates
381 echo "SET session old_alter_table=1;\n";
383 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
391 echo "SET session old_alter_table=0;\n";
393 echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
394 echo "DROP TABLE `".$name."`;\n";
395 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
401 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
403 // Ensure index conversion to unique removes duplicates
406 $db->q("SET session old_alter_table=1;");
408 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
409 if (!dbm::is_result($r)) {
410 $errors .= print_update_error($db, $sql3);
417 if (!dbm::is_result($r)) {
418 $errors .= print_update_error($db, $sql3);
422 $db->q("SET session old_alter_table=0;");
424 $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
425 if (!dbm::is_result($r)) {
426 $errors .= print_update_error($db, $sql3);
429 $r = $db->q("DROP TABLE `".$name."`;");
430 if (!dbm::is_result($r)) {
431 $errors .= print_update_error($db, $sql3);
434 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
435 if (!dbm::is_result($r)) {
436 $errors .= print_update_error($db, $sql3);
446 Config::set('system', 'maintenance', 0);
447 Config::set('system', 'maintenance_reason', '');
453 function db_field_command($parameters, $create = true) {
454 $fieldstruct = $parameters["type"];
456 if (!is_null($parameters["Collation"])) {
457 $fieldstruct .= " COLLATE ".$parameters["Collation"];
460 if ($parameters["not null"])
461 $fieldstruct .= " NOT NULL";
463 if (isset($parameters["default"])){
464 if (strpos(strtolower($parameters["type"]),"int")!==false) {
465 $fieldstruct .= " DEFAULT ".$parameters["default"];
467 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
470 if ($parameters["extra"] != "")
471 $fieldstruct .= " ".$parameters["extra"];
473 /*if (($parameters["primary"] != "") AND $create)
474 $fieldstruct .= " PRIMARY KEY";*/
476 return($fieldstruct);
479 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
487 $primary_keys = array();
488 foreach ($fields AS $fieldname => $field) {
489 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
490 if (x($field,'primary') and $field['primary']!=''){
491 $primary_keys[] = $fieldname;
495 if (!is_null($indexes)) {
496 foreach ($indexes AS $indexname => $fieldnames) {
497 $sql_index = db_create_index($indexname, $fieldnames, "");
498 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
502 $sql = implode(",\n\t", $sql_rows);
504 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
514 function db_add_table_field($fieldname, $parameters) {
515 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
519 function db_modify_table_field($fieldname, $parameters) {
520 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
524 function db_drop_index($indexname) {
525 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
529 function db_create_index($indexname, $fieldnames, $method="ADD") {
531 $method = strtoupper(trim($method));
532 if ($method!="" && $method!="ADD") {
533 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
537 if ($fieldnames[0] == "UNIQUE") {
538 array_shift($fieldnames);
539 $method .= ' UNIQUE';
543 foreach ($fieldnames AS $fieldname) {
547 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
548 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
550 $names .= "`".dbesc($fieldname)."`";
554 if ($indexname == "PRIMARY") {
555 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
559 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
563 function db_group_by($indexname, $fieldnames) {
565 if ($fieldnames[0] != "UNIQUE") {
569 array_shift($fieldnames);
572 foreach ($fieldnames AS $fieldname) {
576 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
577 $names .= "`".dbesc($matches[1])."`";
579 $names .= "`".dbesc($fieldname)."`";
583 $sql = sprintf(" GROUP BY %s", $names);
587 function db_definition() {
591 $database["addon"] = array(
593 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
594 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
595 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
596 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
597 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
598 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
599 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
602 "PRIMARY" => array("id"),
603 "name" => array("UNIQUE", "name"),
606 $database["attach"] = array(
608 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
609 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
610 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
611 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
612 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
613 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
614 "data" => array("type" => "longblob", "not null" => "1"),
615 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
616 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
617 "allow_cid" => array("type" => "mediumtext"),
618 "allow_gid" => array("type" => "mediumtext"),
619 "deny_cid" => array("type" => "mediumtext"),
620 "deny_gid" => array("type" => "mediumtext"),
623 "PRIMARY" => array("id"),
626 $database["auth_codes"] = array(
628 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
629 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
630 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
631 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
632 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
635 "PRIMARY" => array("id"),
638 $database["cache"] = array(
640 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
641 "v" => array("type" => "mediumtext"),
642 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
643 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
646 "PRIMARY" => array("k"),
647 "expire_mode_updated" => array("expire_mode", "updated"),
650 $database["challenge"] = array(
652 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
653 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
654 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
655 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
656 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
657 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
660 "PRIMARY" => array("id"),
663 $database["clients"] = array(
665 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
666 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
667 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
668 "name" => array("type" => "text"),
669 "icon" => array("type" => "text"),
670 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
673 "PRIMARY" => array("client_id"),
676 $database["config"] = array(
678 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
679 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
680 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
681 "v" => array("type" => "mediumtext"),
684 "PRIMARY" => array("id"),
685 "cat_k" => array("UNIQUE", "cat", "k"),
688 $database["contact"] = array(
690 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
691 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
692 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
693 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
694 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
695 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
696 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
697 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
698 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
700 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
701 "about" => array("type" => "text"),
702 "keywords" => array("type" => "text"),
703 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
704 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
705 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
706 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
707 "photo" => array("type" => "text"),
708 "thumb" => array("type" => "text"),
709 "micro" => array("type" => "text"),
710 "site-pubkey" => array("type" => "text"),
711 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
712 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
713 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
714 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
715 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
716 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
717 "pubkey" => array("type" => "text"),
718 "prvkey" => array("type" => "text"),
719 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
720 "request" => array("type" => "text"),
721 "notify" => array("type" => "text"),
722 "poll" => array("type" => "text"),
723 "confirm" => array("type" => "text"),
724 "poco" => array("type" => "text"),
725 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
726 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
727 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
728 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
729 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
731 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
732 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
733 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
734 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
735 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
736 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
737 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
738 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
739 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
740 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
741 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
742 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
743 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
744 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
745 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
746 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
747 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
748 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
749 "reason" => array("type" => "text"),
750 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
751 "info" => array("type" => "mediumtext"),
752 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
753 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
754 "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
755 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
756 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
757 "ffi_keyword_blacklist" => array("type" => "text"),
760 "PRIMARY" => array("id"),
761 "uid_name" => array("uid", "name(190)"),
762 "self_uid" => array("self", "uid"),
763 "alias_uid" => array("alias(32)", "uid"),
764 "pending_uid" => array("pending", "uid"),
765 "blocked_uid" => array("blocked", "uid"),
766 "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
767 "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
768 "addr_uid" => array("addr(32)", "uid"),
769 "nurl_uid" => array("nurl(32)", "uid"),
770 "nick_uid" => array("nick(32)", "uid"),
771 "dfrn-id" => array("dfrn-id"),
772 "issued-id" => array("issued-id"),
775 $database["conv"] = array(
777 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
778 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
779 "recips" => array("type" => "text"),
780 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
781 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
782 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
783 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
784 "subject" => array("type" => "text"),
787 "PRIMARY" => array("id"),
788 "uid" => array("uid"),
791 $database["event"] = array(
793 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
794 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
795 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
796 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
797 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
798 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
799 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
800 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
801 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
802 "summary" => array("type" => "text"),
803 "desc" => array("type" => "text"),
804 "location" => array("type" => "text"),
805 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
806 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
807 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
808 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
809 "allow_cid" => array("type" => "mediumtext"),
810 "allow_gid" => array("type" => "mediumtext"),
811 "deny_cid" => array("type" => "mediumtext"),
812 "deny_gid" => array("type" => "mediumtext"),
815 "PRIMARY" => array("id"),
816 "uid_start" => array("uid", "start"),
819 $database["fcontact"] = array(
821 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
822 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
823 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
824 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
825 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
826 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
827 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
828 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
829 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
830 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
831 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
832 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
833 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
834 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
835 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
836 "pubkey" => array("type" => "text"),
837 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
840 "PRIMARY" => array("id"),
841 "addr" => array("addr(32)"),
842 "url" => array("url"),
845 $database["ffinder"] = array(
847 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
848 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
849 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
850 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
853 "PRIMARY" => array("id"),
856 $database["fserver"] = array(
858 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
859 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
860 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
861 "key" => array("type" => "text"),
864 "PRIMARY" => array("id"),
865 "server" => array("server(32)"),
868 $database["fsuggest"] = array(
870 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
871 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
872 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
873 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
875 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
877 "note" => array("type" => "text"),
878 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
881 "PRIMARY" => array("id"),
884 $database["gcign"] = array(
886 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
887 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
888 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
891 "PRIMARY" => array("id"),
892 "uid" => array("uid"),
893 "gcid" => array("gcid"),
896 $database["gcontact"] = array(
898 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
899 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
902 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
903 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
904 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
905 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
906 "updated" => array("type" => "datetime", "default" => NULL_DATE),
907 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
908 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
909 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
910 "about" => array("type" => "text"),
911 "keywords" => array("type" => "text"),
912 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
913 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
914 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
915 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
916 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
917 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
918 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
919 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
920 "notify" => array("type" => "text"),
921 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
922 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
923 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
926 "PRIMARY" => array("id"),
927 "nurl" => array("nurl(64)"),
928 "name" => array("name(64)"),
929 "nick" => array("nick(32)"),
930 "addr" => array("addr(64)"),
931 "hide_network_updated" => array("hide", "network(4)", "updated"),
932 "updated" => array("updated"),
935 $database["glink"] = array(
937 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
938 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
939 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
940 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
941 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
942 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
945 "PRIMARY" => array("id"),
946 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
947 "gcid" => array("gcid"),
950 $database["group"] = array(
952 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
953 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
954 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
955 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
956 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "PRIMARY" => array("id"),
960 "uid" => array("uid"),
963 $database["group_member"] = array(
965 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
966 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
967 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
968 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
971 "PRIMARY" => array("id"),
972 "contactid" => array("contact-id"),
973 "gid_contactid" => array("gid", "contact-id"),
974 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
977 $database["gserver"] = array(
979 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
980 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
981 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
982 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
983 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
984 "info" => array("type" => "text"),
985 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
986 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
987 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
988 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
989 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
990 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
991 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
992 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
993 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
996 "PRIMARY" => array("id"),
997 "nurl" => array("nurl(32)"),
1000 $database["hook"] = array(
1002 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1003 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1004 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1005 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1006 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1009 "PRIMARY" => array("id"),
1010 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
1013 $database["intro"] = array(
1015 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1016 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1017 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1018 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1019 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1020 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1021 "note" => array("type" => "text"),
1022 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1024 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1025 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1028 "PRIMARY" => array("id"),
1031 $database["item"] = array(
1033 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1034 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1036 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1037 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1038 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1039 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1040 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1041 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1042 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1043 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1047 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1048 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1049 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1050 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1051 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1052 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1053 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1054 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1055 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1056 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1057 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1058 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1059 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1060 "body" => array("type" => "mediumtext"),
1061 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1062 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1063 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1064 "object" => array("type" => "text"),
1065 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1066 "target" => array("type" => "text"),
1067 "postopts" => array("type" => "text"),
1068 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1069 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1070 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1071 "tag" => array("type" => "mediumtext"),
1072 "attach" => array("type" => "mediumtext"),
1073 "inform" => array("type" => "mediumtext"),
1074 "file" => array("type" => "mediumtext"),
1075 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1076 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1077 "allow_cid" => array("type" => "mediumtext"),
1078 "allow_gid" => array("type" => "mediumtext"),
1079 "deny_cid" => array("type" => "mediumtext"),
1080 "deny_gid" => array("type" => "mediumtext"),
1081 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1082 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1083 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1084 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1085 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1086 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1087 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1088 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1089 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1090 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1091 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1092 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1093 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1094 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1095 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1096 "rendered-html" => array("type" => "mediumtext"),
1097 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1100 "PRIMARY" => array("id"),
1101 "guid" => array("guid"),
1102 "uri" => array("uri"),
1103 "parent" => array("parent"),
1104 "parent-uri" => array("parent-uri"),
1105 "extid" => array("extid"),
1106 "uid_id" => array("uid","id"),
1107 "uid_contactid_id" => array("uid","contact-id","id"),
1108 "uid_created" => array("uid","created"),
1109 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1110 "uid_network_received" => array("uid","network(4)","received"),
1111 "uid_network_commented" => array("uid","network(4)","commented"),
1112 "uid_thrparent" => array("uid","thr-parent(190)"),
1113 "uid_parenturi" => array("uid","parent-uri(190)"),
1114 "uid_contactid_created" => array("uid","contact-id","created"),
1115 "authorid_created" => array("author-id","created"),
1116 "uid_uri" => array("uid", "uri(190)"),
1117 "resource-id" => array("resource-id"),
1118 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1119 "uid_type_changed" => array("uid","type(190)","changed"),
1120 "contactid_verb" => array("contact-id","verb(190)"),
1121 "deleted_changed" => array("deleted","changed"),
1122 "uid_wall_changed" => array("uid","wall","changed"),
1123 "uid_eventid" => array("uid","event-id"),
1124 "uid_authorlink" => array("uid","author-link(190)"),
1125 "uid_ownerlink" => array("uid","owner-link(190)"),
1128 $database["item_id"] = array(
1130 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1131 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1132 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1133 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1137 "PRIMARY" => array("id"),
1138 "uid" => array("uid"),
1139 "sid" => array("sid"),
1140 "service" => array("service(32)"),
1141 "iid" => array("iid"),
1144 $database["locks"] = array(
1146 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1147 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1148 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1149 "created" => array("type" => "datetime", "default" => NULL_DATE),
1152 "PRIMARY" => array("id"),
1155 $database["mail"] = array(
1157 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1158 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1159 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1160 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1161 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1162 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1163 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1164 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1165 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1166 "body" => array("type" => "mediumtext"),
1167 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1168 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1169 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1170 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1171 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1172 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1173 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1176 "PRIMARY" => array("id"),
1177 "uid_seen" => array("uid", "seen"),
1178 "convid" => array("convid"),
1179 "uri" => array("uri(64)"),
1180 "parent-uri" => array("parent-uri(64)"),
1183 $database["mailacct"] = array(
1185 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1186 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1187 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1188 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1189 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1190 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1191 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1192 "pass" => array("type" => "text"),
1193 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1194 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1195 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1196 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1197 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1200 "PRIMARY" => array("id"),
1203 $database["manage"] = array(
1205 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1206 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1207 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1210 "PRIMARY" => array("id"),
1211 "uid_mid" => array("UNIQUE", "uid","mid"),
1214 $database["notify"] = array(
1216 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1217 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1218 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1219 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1220 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1221 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1222 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1223 "msg" => array("type" => "mediumtext"),
1224 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1225 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1226 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1227 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1228 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1229 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1230 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1231 "name_cache" => array("type" => "tinytext"),
1232 "msg_cache" => array("type" => "mediumtext")
1235 "PRIMARY" => array("id"),
1236 "hash_uid" => array("hash", "uid"),
1237 "seen_uid_date" => array("seen", "uid", "date"),
1238 "uid_date" => array("uid", "date"),
1239 "uid_type_link" => array("uid", "type", "link(190)"),
1242 $database["notify-threads"] = array(
1244 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1245 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1246 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1247 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1248 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1251 "PRIMARY" => array("id"),
1254 $database["oembed"] = array(
1256 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1257 "content" => array("type" => "mediumtext"),
1258 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1261 "PRIMARY" => array("url"),
1262 "created" => array("created"),
1265 $database["parsed_url"] = array(
1267 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1268 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1269 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1270 "content" => array("type" => "mediumtext"),
1271 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1274 "PRIMARY" => array("url", "guessing", "oembed"),
1275 "created" => array("created"),
1278 $database["pconfig"] = array(
1280 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1281 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1282 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1283 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1284 "v" => array("type" => "mediumtext"),
1287 "PRIMARY" => array("id"),
1288 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1291 $database["photo"] = array(
1293 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1294 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1295 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1296 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1297 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1298 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1299 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1300 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1301 "desc" => array("type" => "text"),
1302 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1303 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1304 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1305 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1306 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1307 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1308 "data" => array("type" => "mediumblob", "not null" => "1"),
1309 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1310 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1311 "allow_cid" => array("type" => "mediumtext"),
1312 "allow_gid" => array("type" => "mediumtext"),
1313 "deny_cid" => array("type" => "mediumtext"),
1314 "deny_gid" => array("type" => "mediumtext"),
1317 "PRIMARY" => array("id"),
1318 "uid_contactid" => array("uid", "contact-id"),
1319 "uid_profile" => array("uid", "profile"),
1320 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1321 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1322 "resource-id" => array("resource-id(64)"),
1325 $database["poll"] = array(
1327 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1328 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1329 "q0" => array("type" => "text"),
1330 "q1" => array("type" => "text"),
1331 "q2" => array("type" => "text"),
1332 "q3" => array("type" => "text"),
1333 "q4" => array("type" => "text"),
1334 "q5" => array("type" => "text"),
1335 "q6" => array("type" => "text"),
1336 "q7" => array("type" => "text"),
1337 "q8" => array("type" => "text"),
1338 "q9" => array("type" => "text"),
1341 "PRIMARY" => array("id"),
1342 "uid" => array("uid"),
1345 $database["poll_result"] = array(
1347 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1348 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1349 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1352 "PRIMARY" => array("id"),
1353 "poll_id" => array("poll_id"),
1354 "choice" => array("choice"),
1357 $database["process"] = array(
1359 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1360 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1361 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1364 "PRIMARY" => array("pid"),
1365 "command" => array("command"),
1368 $database["profile"] = array(
1370 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1371 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1372 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1373 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1374 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1375 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1376 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1377 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
1378 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1379 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1380 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1381 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1382 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1383 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1384 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1385 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1386 "with" => array("type" => "text"),
1387 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1388 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1389 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1390 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1391 "pub_keywords" => array("type" => "text"),
1392 "prv_keywords" => array("type" => "text"),
1393 "likes" => array("type" => "text"),
1394 "dislikes" => array("type" => "text"),
1395 "about" => array("type" => "text"),
1396 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1397 "music" => array("type" => "text"),
1398 "book" => array("type" => "text"),
1399 "tv" => array("type" => "text"),
1400 "film" => array("type" => "text"),
1401 "interest" => array("type" => "text"),
1402 "romance" => array("type" => "text"),
1403 "work" => array("type" => "text"),
1404 "education" => array("type" => "text"),
1405 "contact" => array("type" => "text"),
1406 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1407 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1408 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1409 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1410 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1411 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1414 "PRIMARY" => array("id"),
1415 "uid_is-default" => array("uid", "is-default"),
1418 $database["profile_check"] = array(
1420 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1421 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1422 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1423 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1424 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1425 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1428 "PRIMARY" => array("id"),
1431 $database["push_subscriber"] = array(
1433 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1434 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1435 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1436 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1437 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1438 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1439 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1440 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1443 "PRIMARY" => array("id"),
1446 $database["queue"] = array(
1448 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1449 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1450 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1451 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1452 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1453 "content" => array("type" => "mediumtext"),
1454 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1457 "PRIMARY" => array("id"),
1458 "cid" => array("cid"),
1459 "created" => array("created"),
1460 "last" => array("last"),
1461 "network" => array("network"),
1462 "batch" => array("batch"),
1465 $database["register"] = array(
1467 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1468 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1469 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1470 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1471 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1472 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1473 "note" => array("type" => "text"),
1476 "PRIMARY" => array("id"),
1479 $database["search"] = array(
1481 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1482 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1483 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1486 "PRIMARY" => array("id"),
1487 "uid" => array("uid"),
1490 $database["session"] = array(
1492 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1493 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1494 "data" => array("type" => "text"),
1495 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1498 "PRIMARY" => array("id"),
1499 "sid" => array("sid(64)"),
1500 "expire" => array("expire"),
1503 $database["sign"] = array(
1505 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1506 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1507 "signed_text" => array("type" => "mediumtext"),
1508 "signature" => array("type" => "text"),
1509 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1512 "PRIMARY" => array("id"),
1513 "iid" => array("iid"),
1516 $database["spam"] = array(
1518 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1519 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1520 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1521 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1522 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1523 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1526 "PRIMARY" => array("id"),
1527 "uid" => array("uid"),
1528 "spam" => array("spam"),
1529 "ham" => array("ham"),
1530 "term" => array("term"),
1533 $database["term"] = array(
1535 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1536 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1537 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1538 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1539 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1540 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1541 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1542 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1543 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1544 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1545 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1546 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1549 "PRIMARY" => array("tid"),
1550 "oid_otype_type_term" => array("oid","otype","type","term(32)"),
1551 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1552 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1553 "guid" => array("guid(64)"),
1556 $database["thread"] = array(
1558 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1559 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1560 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1561 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1562 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1563 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1564 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1565 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1566 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1567 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1568 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1569 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1570 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1571 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1572 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1573 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1574 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1575 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1576 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1577 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1578 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1579 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1580 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1581 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1582 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1583 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1586 "PRIMARY" => array("iid"),
1587 "uid_network_commented" => array("uid","network","commented"),
1588 "uid_network_created" => array("uid","network","created"),
1589 "uid_contactid_commented" => array("uid","contact-id","commented"),
1590 "uid_contactid_created" => array("uid","contact-id","created"),
1591 "uid_created" => array("uid","created"),
1592 "uid_commented" => array("uid","commented"),
1593 "uid_wall_created" => array("uid","wall","created"),
1596 $database["tokens"] = array(
1598 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1599 "secret" => array("type" => "text"),
1600 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1601 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1602 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1603 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1606 "PRIMARY" => array("id"),
1609 $database["user"] = array(
1611 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1612 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1613 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1614 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1615 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1616 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1617 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1618 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1619 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1620 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1621 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1622 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1623 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1624 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1625 "pubkey" => array("type" => "text"),
1626 "prvkey" => array("type" => "text"),
1627 "spubkey" => array("type" => "text"),
1628 "sprvkey" => array("type" => "text"),
1629 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1630 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1631 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1632 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1633 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1634 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1635 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1636 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1637 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1638 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1639 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1640 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1641 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1642 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1643 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1644 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1645 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1646 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1647 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1648 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1649 "allow_cid" => array("type" => "mediumtext"),
1650 "allow_gid" => array("type" => "mediumtext"),
1651 "deny_cid" => array("type" => "mediumtext"),
1652 "deny_gid" => array("type" => "mediumtext"),
1653 "openidserver" => array("type" => "text"),
1656 "PRIMARY" => array("uid"),
1657 "nickname" => array("nickname(32)"),
1660 $database["userd"] = array(
1662 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1663 "username" => array("type" => "varchar(255)", "not null" => "1"),
1666 "PRIMARY" => array("id"),
1667 "username" => array("username(32)"),
1670 $database["workerqueue"] = array(
1672 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1673 "parameter" => array("type" => "text"),
1674 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1675 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1676 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1677 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1680 "PRIMARY" => array("id"),
1689 * run from command line
1691 function dbstructure_run(&$argv, &$argc) {
1699 @include(".htconfig.php");
1700 require_once("include/dba.php");
1701 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1702 unset($db_host, $db_user, $db_pass, $db_data);
1708 update_structure(true, false);
1711 update_structure(true, true);
1713 $build = get_config('system','build');
1715 set_config('system','build',DB_UPDATE_VERSION);
1716 $build = DB_UPDATE_VERSION;
1719 $stored = intval($build);
1720 $current = intval(DB_UPDATE_VERSION);
1722 // run any left update_nnnn functions in update.php
1723 for ($x = $stored; $x < $current; $x ++) {
1724 $r = run_update_function($x);
1728 set_config('system','build',DB_UPDATE_VERSION);
1731 print_structure(db_definition());
1738 echo $argv[0]." <command>\n";
1741 echo "dryrun show database update schema queries without running them\n";
1742 echo "update update database schema\n";
1743 echo "dumpsql dump database schema\n";
1748 if (array_search(__file__,get_included_files())===0){
1749 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);