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 // Define the default collation if not given
284 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
285 $parameters['Collation'] = 'utf8mb4_general_ci';
287 $parameters['Collation'] = null;
290 $current_field_definition = implode(",", $field_definition);
291 $new_field_definition = implode(",", $parameters);
292 if ($current_field_definition != $new_field_definition) {
293 $sql2 = db_modify_table_field($fieldname, $parameters);
295 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
305 * Create the index if the index don't exists in database
306 * or the definition differ from the current status.
307 * Don't create keys if table is new
309 if (!$is_new_table) {
310 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
311 if (isset($database[$name]["indexes"][$indexname])) {
312 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
314 $current_index_definition = "__NOT_SET__";
316 $new_index_definition = implode(",",$fieldnames);
317 if ($current_index_definition != $new_index_definition) {
318 $sql2 = db_create_index($indexname, $fieldnames);
320 // Fetch the "group by" fields for unique indexes
321 if ($fieldnames[0] == "UNIQUE") {
322 $group_by = db_group_by($indexname, $fieldnames);
326 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
334 if (isset($database[$name]["table_status"]["Collation"])) {
335 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
336 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
339 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
350 // Ensure index conversion to unique removes duplicates
353 echo "SET session old_alter_table=1;\n";
355 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
363 echo "SET session old_alter_table=0;\n";
365 echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
366 echo "DROP TABLE `".$name."`;\n";
367 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
373 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
375 // Ensure index conversion to unique removes duplicates
378 $db->q("SET session old_alter_table=1;");
380 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
381 if (!dbm::is_result($r)) {
382 $errors .= print_update_error($db, $sql3);
389 if (!dbm::is_result($r)) {
390 $errors .= print_update_error($db, $sql3);
394 $db->q("SET session old_alter_table=0;");
396 $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
397 if (!dbm::is_result($r)) {
398 $errors .= print_update_error($db, $sql3);
401 $r = $db->q("DROP TABLE `".$name."`;");
402 if (!dbm::is_result($r)) {
403 $errors .= print_update_error($db, $sql3);
406 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
407 if (!dbm::is_result($r)) {
408 $errors .= print_update_error($db, $sql3);
418 Config::set('system', 'maintenance', 0);
419 Config::set('system', 'maintenance_reason', '');
425 function db_field_command($parameters, $create = true) {
426 $fieldstruct = $parameters["type"];
428 if (!is_null($parameters["Collation"])) {
429 $fieldstruct .= " COLLATE ".$parameters["Collation"];
432 if ($parameters["not null"])
433 $fieldstruct .= " NOT NULL";
435 if (isset($parameters["default"])){
436 if (strpos(strtolower($parameters["type"]),"int")!==false) {
437 $fieldstruct .= " DEFAULT ".$parameters["default"];
439 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
442 if ($parameters["extra"] != "")
443 $fieldstruct .= " ".$parameters["extra"];
445 /*if (($parameters["primary"] != "") AND $create)
446 $fieldstruct .= " PRIMARY KEY";*/
448 return($fieldstruct);
451 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
459 $primary_keys = array();
460 foreach($fields AS $fieldname => $field) {
461 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
462 if (x($field,'primary') and $field['primary']!=''){
463 $primary_keys[] = $fieldname;
467 if (!is_null($indexes)) {
468 foreach ($indexes AS $indexname => $fieldnames) {
469 $sql_index = db_create_index($indexname, $fieldnames, "");
470 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
474 $sql = implode(",\n\t", $sql_rows);
476 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
486 function db_add_table_field($fieldname, $parameters) {
487 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
491 function db_modify_table_field($fieldname, $parameters) {
492 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
496 function db_drop_index($indexname) {
497 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
501 function db_create_index($indexname, $fieldnames, $method="ADD") {
503 $method = strtoupper(trim($method));
504 if ($method!="" && $method!="ADD") {
505 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
509 if ($fieldnames[0] == "UNIQUE") {
510 array_shift($fieldnames);
511 $method .= ' UNIQUE';
515 foreach ($fieldnames AS $fieldname) {
519 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
520 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
522 $names .= "`".dbesc($fieldname)."`";
526 if ($indexname == "PRIMARY") {
527 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
531 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
535 function db_group_by($indexname, $fieldnames) {
537 if ($fieldnames[0] != "UNIQUE") {
541 array_shift($fieldnames);
544 foreach ($fieldnames AS $fieldname) {
548 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
549 $names .= "`".dbesc($matches[1])."`";
551 $names .= "`".dbesc($fieldname)."`";
555 $sql = sprintf(" GROUP BY %s", $names);
559 function db_definition() {
563 $database["addon"] = array(
565 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
566 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
567 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
568 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
569 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
570 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
571 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
574 "PRIMARY" => array("id"),
575 "name" => array("UNIQUE", "name"),
578 $database["attach"] = array(
580 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
581 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
582 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
583 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
584 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
585 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
586 "data" => array("type" => "longblob", "not null" => "1"),
587 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
588 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
589 "allow_cid" => array("type" => "mediumtext"),
590 "allow_gid" => array("type" => "mediumtext"),
591 "deny_cid" => array("type" => "mediumtext"),
592 "deny_gid" => array("type" => "mediumtext"),
595 "PRIMARY" => array("id"),
598 $database["auth_codes"] = array(
600 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
601 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
602 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
603 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
604 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
607 "PRIMARY" => array("id"),
610 $database["cache"] = array(
612 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
613 "v" => array("type" => "mediumtext"),
614 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
615 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
618 "PRIMARY" => array("k"),
619 "expire_mode_updated" => array("expire_mode", "updated"),
622 $database["challenge"] = array(
624 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
625 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
626 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
627 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
628 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
629 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "PRIMARY" => array("id"),
635 $database["clients"] = array(
637 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
638 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
639 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
640 "name" => array("type" => "text"),
641 "icon" => array("type" => "text"),
642 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
645 "PRIMARY" => array("client_id"),
648 $database["config"] = array(
650 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
651 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
652 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
653 "v" => array("type" => "mediumtext"),
656 "PRIMARY" => array("id"),
657 "cat_k" => array("UNIQUE", "cat", "k"),
660 $database["contact"] = array(
662 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
663 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
664 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
665 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
666 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
667 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
668 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
669 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
670 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
671 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
672 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
673 "about" => array("type" => "text"),
674 "keywords" => array("type" => "text"),
675 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
676 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
677 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
678 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
679 "photo" => array("type" => "text"),
680 "thumb" => array("type" => "text"),
681 "micro" => array("type" => "text"),
682 "site-pubkey" => array("type" => "text"),
683 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
684 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
685 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
686 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
687 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
688 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
689 "pubkey" => array("type" => "text"),
690 "prvkey" => array("type" => "text"),
691 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
692 "request" => array("type" => "text"),
693 "notify" => array("type" => "text"),
694 "poll" => array("type" => "text"),
695 "confirm" => array("type" => "text"),
696 "poco" => array("type" => "text"),
697 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
698 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
699 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
700 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
701 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
702 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
703 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
704 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
705 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
706 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
707 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
708 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
709 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
710 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
711 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
712 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
713 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
714 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
715 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
716 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
717 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
718 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
719 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
720 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
721 "reason" => array("type" => "text"),
722 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
723 "info" => array("type" => "mediumtext"),
724 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
725 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
726 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
727 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
728 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
729 "ffi_keyword_blacklist" => array("type" => "text"),
732 "PRIMARY" => array("id"),
733 "uid_name" => array("uid", "name"),
734 "self_uid" => array("self", "uid"),
735 "alias_uid" => array("alias(32)", "uid"),
736 "pending_uid" => array("pending", "uid"),
737 "blocked_uid" => array("blocked", "uid"),
738 "uid_rel_network_poll" => array("uid", "rel", "network", "poll(64)", "archive"),
739 "uid_network_batch" => array("uid", "network", "batch(64)"),
740 "addr_uid" => array("addr(32)", "uid"),
741 "nurl_uid" => array("nurl(32)", "uid"),
742 "nick_uid" => array("nick(32)", "uid"),
743 "dfrn-id" => array("dfrn-id"),
744 "issued-id" => array("issued-id"),
747 $database["conv"] = array(
749 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
750 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
751 "recips" => array("type" => "text"),
752 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
753 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
755 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
756 "subject" => array("type" => "text"),
759 "PRIMARY" => array("id"),
760 "uid" => array("uid"),
763 $database["event"] = array(
765 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
766 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
767 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
768 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
769 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
770 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
771 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
772 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
773 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
774 "summary" => array("type" => "text"),
775 "desc" => array("type" => "text"),
776 "location" => array("type" => "text"),
777 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
778 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
779 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
780 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
781 "allow_cid" => array("type" => "mediumtext"),
782 "allow_gid" => array("type" => "mediumtext"),
783 "deny_cid" => array("type" => "mediumtext"),
784 "deny_gid" => array("type" => "mediumtext"),
787 "PRIMARY" => array("id"),
788 "uid_start" => array("uid", "start"),
791 $database["fcontact"] = array(
793 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
794 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
795 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
796 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
797 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
798 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
799 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
800 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
801 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
802 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
803 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
804 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
805 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
806 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
807 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
808 "pubkey" => array("type" => "text"),
809 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
812 "PRIMARY" => array("id"),
813 "addr" => array("addr(32)"),
814 "url" => array("url"),
817 $database["ffinder"] = array(
819 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
820 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
821 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
822 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
825 "PRIMARY" => array("id"),
828 $database["fserver"] = array(
830 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
831 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
832 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
833 "key" => array("type" => "text"),
836 "PRIMARY" => array("id"),
837 "server" => array("server(32)"),
840 $database["fsuggest"] = array(
842 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
843 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
844 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
845 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
846 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
847 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
848 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
849 "note" => array("type" => "text"),
850 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
853 "PRIMARY" => array("id"),
856 $database["gcign"] = array(
858 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
859 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
860 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
863 "PRIMARY" => array("id"),
864 "uid" => array("uid"),
865 "gcid" => array("gcid"),
868 $database["gcontact"] = array(
870 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
871 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
872 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
873 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
875 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
877 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
878 "updated" => array("type" => "datetime", "default" => NULL_DATE),
879 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
880 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
881 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
882 "about" => array("type" => "text"),
883 "keywords" => array("type" => "text"),
884 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
885 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
886 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
887 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
888 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
889 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
890 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
892 "notify" => array("type" => "text"),
893 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
894 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
895 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
898 "PRIMARY" => array("id"),
899 "nurl" => array("nurl(64)"),
900 "name" => array("name(64)"),
901 "nick" => array("nick(32)"),
902 "addr" => array("addr(64)"),
903 "hide_network_updated" => array("hide", "network", "updated"),
904 "updated" => array("updated"),
907 $database["glink"] = array(
909 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
910 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
911 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
912 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
913 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
914 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
917 "PRIMARY" => array("id"),
918 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
919 "gcid" => array("gcid"),
922 $database["group"] = array(
924 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
925 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
926 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
927 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
928 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
931 "PRIMARY" => array("id"),
932 "uid" => array("uid"),
935 $database["group_member"] = array(
937 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
938 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
939 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
940 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
943 "PRIMARY" => array("id"),
944 "contactid" => array("contact-id"),
945 "gid_contactid" => array("gid", "contact-id"),
946 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
949 $database["gserver"] = array(
951 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
952 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
953 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
954 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
955 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
956 "info" => array("type" => "text"),
957 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
958 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
961 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
963 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
964 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
965 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
968 "PRIMARY" => array("id"),
969 "nurl" => array("nurl(32)"),
972 $database["hook"] = array(
974 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
975 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
976 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
977 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
978 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
981 "PRIMARY" => array("id"),
982 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
985 $database["intro"] = array(
987 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
988 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
989 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
990 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
991 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
992 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
993 "note" => array("type" => "text"),
994 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
995 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
996 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
997 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1000 "PRIMARY" => array("id"),
1003 $database["item"] = array(
1005 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1006 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1007 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1008 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1009 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1010 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1011 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1012 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1013 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1014 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1015 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1016 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1017 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1018 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1019 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1020 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1021 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1022 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1023 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1024 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1025 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1026 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1027 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1028 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1029 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1030 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1031 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1032 "body" => array("type" => "mediumtext"),
1033 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1034 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1036 "object" => array("type" => "text"),
1037 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038 "target" => array("type" => "text"),
1039 "postopts" => array("type" => "text"),
1040 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1042 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1043 "tag" => array("type" => "mediumtext"),
1044 "attach" => array("type" => "mediumtext"),
1045 "inform" => array("type" => "mediumtext"),
1046 "file" => array("type" => "mediumtext"),
1047 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049 "allow_cid" => array("type" => "mediumtext"),
1050 "allow_gid" => array("type" => "mediumtext"),
1051 "deny_cid" => array("type" => "mediumtext"),
1052 "deny_gid" => array("type" => "mediumtext"),
1053 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1054 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1055 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1056 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1057 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1058 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1059 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1060 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1061 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1062 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1063 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1064 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1065 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1066 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1067 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1068 "rendered-html" => array("type" => "mediumtext"),
1069 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1072 "PRIMARY" => array("id"),
1073 "guid" => array("guid"),
1074 "uri" => array("uri"),
1075 "parent" => array("parent"),
1076 "parent-uri" => array("parent-uri"),
1077 "extid" => array("extid"),
1078 "uid_id" => array("uid","id"),
1079 "uid_contactid_id" => array("uid","contact-id","id"),
1080 "uid_created" => array("uid","created"),
1081 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1082 "uid_network_received" => array("uid","network","received"),
1083 "uid_network_commented" => array("uid","network","commented"),
1084 "uid_thrparent" => array("uid","thr-parent"),
1085 "uid_parenturi" => array("uid","parent-uri"),
1086 "uid_contactid_created" => array("uid","contact-id","created"),
1087 "authorid_created" => array("author-id","created"),
1088 "uid_uri" => array("uid", "uri"),
1089 "resource-id" => array("resource-id"),
1090 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1091 "uid_type_changed" => array("uid","type","changed"),
1092 "contactid_verb" => array("contact-id","verb"),
1093 "deleted_changed" => array("deleted","changed"),
1094 "uid_wall_changed" => array("uid","wall","changed"),
1095 "uid_eventid" => array("uid","event-id"),
1096 "uid_authorlink" => array("uid","author-link"),
1097 "uid_ownerlink" => array("uid","owner-link"),
1100 $database["item_id"] = array(
1102 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1103 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1104 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1105 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1109 "PRIMARY" => array("id"),
1110 "uid" => array("uid"),
1111 "sid" => array("sid"),
1112 "service" => array("service(32)"),
1113 "iid" => array("iid"),
1116 $database["locks"] = array(
1118 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1119 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1120 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1121 "created" => array("type" => "datetime", "default" => NULL_DATE),
1124 "PRIMARY" => array("id"),
1127 $database["mail"] = array(
1129 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1130 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1131 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1132 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1133 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1135 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1136 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1137 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1138 "body" => array("type" => "mediumtext"),
1139 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1140 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1141 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1142 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1143 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1144 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1145 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1148 "PRIMARY" => array("id"),
1149 "uid_seen" => array("uid", "seen"),
1150 "convid" => array("convid"),
1151 "uri" => array("uri(64)"),
1152 "parent-uri" => array("parent-uri(64)"),
1155 $database["mailacct"] = array(
1157 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1158 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1159 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1160 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1161 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1162 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1163 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1164 "pass" => array("type" => "text"),
1165 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1166 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1167 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1168 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1169 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1172 "PRIMARY" => array("id"),
1175 $database["manage"] = array(
1177 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1178 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1179 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1182 "PRIMARY" => array("id"),
1183 "uid_mid" => array("UNIQUE", "uid","mid"),
1186 $database["notify"] = array(
1188 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1189 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1190 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1191 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1192 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1193 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1194 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1195 "msg" => array("type" => "mediumtext"),
1196 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1197 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1198 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1199 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1200 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1201 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1202 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1203 "name_cache" => array("type" => "tinytext"),
1204 "msg_cache" => array("type" => "mediumtext")
1207 "PRIMARY" => array("id"),
1208 "hash_uid" => array("hash", "uid"),
1209 "seen_uid_date" => array("seen", "uid", "date"),
1210 "uid_date" => array("uid", "date"),
1211 "uid_type_link" => array("uid", "type", "link"),
1214 $database["notify-threads"] = array(
1216 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1217 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1218 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1219 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1220 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1223 "PRIMARY" => array("id"),
1226 $database["oembed"] = array(
1228 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1229 "content" => array("type" => "mediumtext"),
1230 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1233 "PRIMARY" => array("url"),
1234 "created" => array("created"),
1237 $database["parsed_url"] = array(
1239 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1240 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1241 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1242 "content" => array("type" => "mediumtext"),
1243 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1246 "PRIMARY" => array("url", "guessing", "oembed"),
1247 "created" => array("created"),
1250 $database["pconfig"] = array(
1252 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1253 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1254 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1255 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1256 "v" => array("type" => "mediumtext"),
1259 "PRIMARY" => array("id"),
1260 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1263 $database["photo"] = array(
1265 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1266 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1267 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1268 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1269 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1270 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1271 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1272 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1273 "desc" => array("type" => "text"),
1274 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1275 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1276 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1277 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1278 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1279 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1280 "data" => array("type" => "mediumblob", "not null" => "1"),
1281 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1282 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1283 "allow_cid" => array("type" => "mediumtext"),
1284 "allow_gid" => array("type" => "mediumtext"),
1285 "deny_cid" => array("type" => "mediumtext"),
1286 "deny_gid" => array("type" => "mediumtext"),
1289 "PRIMARY" => array("id"),
1290 "uid_contactid" => array("uid", "contact-id"),
1291 "uid_profile" => array("uid", "profile"),
1292 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1293 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1294 "resource-id" => array("resource-id(64)"),
1297 $database["poll"] = array(
1299 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1300 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1301 "q0" => array("type" => "text"),
1302 "q1" => array("type" => "text"),
1303 "q2" => array("type" => "text"),
1304 "q3" => array("type" => "text"),
1305 "q4" => array("type" => "text"),
1306 "q5" => array("type" => "text"),
1307 "q6" => array("type" => "text"),
1308 "q7" => array("type" => "text"),
1309 "q8" => array("type" => "text"),
1310 "q9" => array("type" => "text"),
1313 "PRIMARY" => array("id"),
1314 "uid" => array("uid"),
1317 $database["poll_result"] = array(
1319 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1320 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1321 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1324 "PRIMARY" => array("id"),
1325 "poll_id" => array("poll_id"),
1326 "choice" => array("choice"),
1329 $database["process"] = array(
1331 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1332 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1333 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1336 "PRIMARY" => array("pid"),
1337 "command" => array("command"),
1340 $database["profile"] = array(
1342 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1343 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1344 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1345 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1346 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1347 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1348 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1349 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1350 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1351 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1352 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1353 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1354 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1355 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1356 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1357 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1358 "with" => array("type" => "text"),
1359 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1360 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1361 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1362 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1363 "pub_keywords" => array("type" => "text"),
1364 "prv_keywords" => array("type" => "text"),
1365 "likes" => array("type" => "text"),
1366 "dislikes" => array("type" => "text"),
1367 "about" => array("type" => "text"),
1368 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1369 "music" => array("type" => "text"),
1370 "book" => array("type" => "text"),
1371 "tv" => array("type" => "text"),
1372 "film" => array("type" => "text"),
1373 "interest" => array("type" => "text"),
1374 "romance" => array("type" => "text"),
1375 "work" => array("type" => "text"),
1376 "education" => array("type" => "text"),
1377 "contact" => array("type" => "text"),
1378 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1379 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1380 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1381 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1382 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1383 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1386 "PRIMARY" => array("id"),
1387 "uid_is-default" => array("uid", "is-default"),
1390 $database["profile_check"] = array(
1392 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1393 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1394 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1395 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1396 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1397 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1400 "PRIMARY" => array("id"),
1403 $database["push_subscriber"] = array(
1405 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1406 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1407 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1408 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1409 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1410 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1411 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1412 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1415 "PRIMARY" => array("id"),
1418 $database["queue"] = array(
1420 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1421 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1422 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1423 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1424 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1425 "content" => array("type" => "mediumtext"),
1426 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1429 "PRIMARY" => array("id"),
1430 "cid" => array("cid"),
1431 "created" => array("created"),
1432 "last" => array("last"),
1433 "network" => array("network"),
1434 "batch" => array("batch"),
1437 $database["register"] = array(
1439 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1440 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1441 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1442 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1443 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1444 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1445 "note" => array("type" => "text"),
1448 "PRIMARY" => array("id"),
1451 $database["search"] = array(
1453 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1454 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1455 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1458 "PRIMARY" => array("id"),
1459 "uid" => array("uid"),
1462 $database["session"] = array(
1464 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1465 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1466 "data" => array("type" => "text"),
1467 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1470 "PRIMARY" => array("id"),
1471 "sid" => array("sid(64)"),
1472 "expire" => array("expire"),
1475 $database["sign"] = array(
1477 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1478 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1479 "signed_text" => array("type" => "mediumtext"),
1480 "signature" => array("type" => "text"),
1481 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1484 "PRIMARY" => array("id"),
1485 "iid" => array("iid"),
1488 $database["spam"] = array(
1490 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1491 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1492 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1493 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1494 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1495 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1498 "PRIMARY" => array("id"),
1499 "uid" => array("uid"),
1500 "spam" => array("spam"),
1501 "ham" => array("ham"),
1502 "term" => array("term"),
1505 $database["term"] = array(
1507 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1508 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1509 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1510 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1511 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1512 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1513 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1514 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1515 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1516 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1517 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1518 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1521 "PRIMARY" => array("tid"),
1522 "oid_otype_type_term" => array("oid","otype","type","term"),
1523 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1524 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1525 "guid" => array("guid(64)"),
1528 $database["thread"] = array(
1530 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1531 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1532 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1533 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1534 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1535 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1536 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1537 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1538 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1539 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1540 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1541 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1542 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1543 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1544 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1545 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1546 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1547 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1548 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1549 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1550 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1551 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1552 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1553 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1554 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1555 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1558 "PRIMARY" => array("iid"),
1559 "uid_network_commented" => array("uid","network","commented"),
1560 "uid_network_created" => array("uid","network","created"),
1561 "uid_contactid_commented" => array("uid","contact-id","commented"),
1562 "uid_contactid_created" => array("uid","contact-id","created"),
1563 "uid_created" => array("uid","created"),
1564 "uid_commented" => array("uid","commented"),
1565 "uid_wall_created" => array("uid","wall","created"),
1568 $database["tokens"] = array(
1570 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1571 "secret" => array("type" => "text"),
1572 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1573 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1574 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1575 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1578 "PRIMARY" => array("id"),
1581 $database["user"] = array(
1583 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1584 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1585 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1586 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1587 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1588 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1589 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1590 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1591 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1592 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1593 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1594 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1595 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1596 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1597 "pubkey" => array("type" => "text"),
1598 "prvkey" => array("type" => "text"),
1599 "spubkey" => array("type" => "text"),
1600 "sprvkey" => array("type" => "text"),
1601 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1602 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1603 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1604 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1605 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1606 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1607 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1608 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1609 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1610 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1611 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1612 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1613 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1614 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1615 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1616 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1617 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1618 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1619 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1620 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1621 "allow_cid" => array("type" => "mediumtext"),
1622 "allow_gid" => array("type" => "mediumtext"),
1623 "deny_cid" => array("type" => "mediumtext"),
1624 "deny_gid" => array("type" => "mediumtext"),
1625 "openidserver" => array("type" => "text"),
1628 "PRIMARY" => array("uid"),
1629 "nickname" => array("nickname(32)"),
1632 $database["userd"] = array(
1634 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1635 "username" => array("type" => "varchar(255)", "not null" => "1"),
1638 "PRIMARY" => array("id"),
1639 "username" => array("username(32)"),
1642 $database["workerqueue"] = array(
1644 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1645 "parameter" => array("type" => "text"),
1646 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1647 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1648 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1649 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1652 "PRIMARY" => array("id"),
1661 * run from command line
1663 function dbstructure_run(&$argv, &$argc) {
1671 @include(".htconfig.php");
1672 require_once("include/dba.php");
1673 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1674 unset($db_host, $db_user, $db_pass, $db_data);
1680 update_structure(true, false);
1683 update_structure(true, true);
1685 $build = get_config('system','build');
1687 set_config('system','build',DB_UPDATE_VERSION);
1688 $build = DB_UPDATE_VERSION;
1691 $stored = intval($build);
1692 $current = intval(DB_UPDATE_VERSION);
1694 // run any left update_nnnn functions in update.php
1695 for($x = $stored; $x < $current; $x ++) {
1696 $r = run_update_function($x);
1700 set_config('system','build',DB_UPDATE_VERSION);
1703 print_structure(db_definition());
1710 echo $argv[0]." <command>\n";
1713 echo "dryrun show database update schema queries without running them\n";
1714 echo "update update database schema\n";
1715 echo "dumpsql dump database schema\n";
1720 if (array_search(__file__,get_included_files())===0){
1721 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);