2 require_once("boot.php");
3 require_once("include/text.php");
5 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
8 * send the email and do what is needed to do on update fails
10 * @param update_id (int) number of failed update
11 * @param error_message (str) error message
13 function update_fail($update_id, $error_message){
14 //send the administrators an e-mail
15 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
16 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
21 if (!dbm::is_result($adminlist)) {
22 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
28 // every admin could had different language
29 foreach ($adminlist as $admin) {
30 $lang = (($admin['language'])?$admin['language']:'en');
33 $preamble = deindent(t("
34 The friendica developers released update %s recently,
35 but when I tried to install it, something went terribly wrong.
36 This needs to be fixed soon and I can't do it alone. Please contact a
37 friendica developer if you can not help me on your own. My database might be invalid."));
38 $body = t("The error message is\n[pre]%s[/pre]");
39 $preamble = sprintf($preamble, $update_id);
40 $body = sprintf($body, $error_message);
43 'type' => "SYSTEM_EMAIL",
44 'to_email' => $admin['email'],
45 'preamble' => $preamble,
55 $email_tpl = get_intltext_template("update_fail_eml.tpl");
56 $email_msg = replace_macros($email_tpl, array(
57 '$sitename' => $a->config['sitename'],
58 '$siteurl' => App::get_baseurl(),
59 '$update' => DB_UPDATE_VERSION,
60 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
62 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
63 require_once('include/email.php');
64 $subject = email_header_encode($subject,'UTF-8');
65 mail($a->config['admin_email'], $subject, $email_msg,
66 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
67 .'Content-type: text/plain; charset=UTF-8'."\n"
68 .'Content-transfer-encoding: 8bit');
71 logger("CRITICAL: Database structure update failed: ".$retval);
75 function table_structure($table) {
76 $structures = q("DESCRIBE `%s`", $table);
78 $indexes = q("SHOW INDEX FROM `%s`", $table);
83 if (dbm::is_result($indexes))
84 foreach ($indexes AS $index) {
85 if ($index["Index_type"] == "FULLTEXT") {
89 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
90 $indexdata[$index["Key_name"]] = array('UNIQUE');
93 $column = $index["Column_name"];
94 // On utf8mb4 a varchar index can only have a length of 191
95 // To avoid the need to add this to every index definition we just ignore it here.
96 // Exception are primary indexes
97 // Since there are some combindex primary indexes we use the limit of 180 here.
98 if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) {
99 $column .= "(".$index["Sub_part"].")";
102 $indexdata[$index["Key_name"]][] = $column;
105 if (dbm::is_result($structures)) {
106 foreach ($structures AS $field) {
107 $fielddata[$field["Field"]]["type"] = $field["Type"];
108 if ($field["Null"] == "NO") {
109 $fielddata[$field["Field"]]["not null"] = true;
112 if (isset($field["Default"])) {
113 $fielddata[$field["Field"]]["default"] = $field["Default"];
116 if ($field["Extra"] != "") {
117 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
120 if ($field["Key"] == "PRI") {
121 $fielddata[$field["Field"]]["primary"] = true;
125 return(array("fields"=>$fielddata, "indexes"=>$indexdata));
128 function print_structure($database, $charset) {
129 echo "-- ------------------------------------------\n";
130 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
131 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
132 echo "-- ------------------------------------------\n\n\n";
133 foreach ($database AS $name => $structure) {
135 echo "-- TABLE $name\n";
137 db_create_table($name, $structure['fields'], $charset, true, false, $structure["indexes"]);
143 function update_structure($verbose, $action, $tables=null, $definition=null) {
147 set_config('system', 'maintenance', 1);
150 if (isset($a->config["system"]["db_charset"])) {
151 $charset = $a->config["system"]["db_charset"];
158 logger('updating structure', LOGGER_DEBUG);
160 // Get the current structure
163 if (is_null($tables)) {
164 $tables = q("SHOW TABLES");
167 foreach ($tables AS $table) {
168 $table = current($table);
170 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
171 $database[$table] = table_structure($table);
174 // Get the definition
175 if (is_null($definition)) {
176 $definition = db_definition($charset);
179 // Ensure index conversion to unique removes duplicates
180 $sql_config = "SET session old_alter_table=1;";
182 echo $sql_config."\n";
188 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
189 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
190 !(strpos($db->server_info(), 'MariaDB') !== false)) {
197 foreach ($definition AS $name => $structure) {
198 $is_new_table = False;
200 if (!isset($database[$name])) {
201 $r = db_create_table($name, $structure["fields"], $charset, $verbose, $action, $structure['indexes']);
202 if (!dbm::is_result($r)) {
203 $errors .= t('Errors encountered creating database tables.').$name.EOL;
205 $is_new_table = True;
208 * Drop the index if it isn't present in the definition
209 * or the definition differ from current status
210 * and index name doesn't start with "local_"
212 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
213 $current_index_definition = implode(",",$fieldnames);
214 if (isset($structure["indexes"][$indexname])) {
215 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
217 $new_index_definition = "__NOT_SET__";
219 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
220 $sql2=db_drop_index($indexname);
222 $sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2;
228 // Compare the field structure field by field
229 foreach ($structure["fields"] AS $fieldname => $parameters) {
230 if (!isset($database[$name]["fields"][$fieldname])) {
231 $sql2=db_add_table_field($fieldname, $parameters);
233 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
238 // Compare the field definition
239 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
240 $new_field_definition = implode(",",$parameters);
241 if ($current_field_definition != $new_field_definition) {
242 $sql2=db_modify_table_field($fieldname, $parameters);
244 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
255 * Create the index if the index don't exists in database
256 * or the definition differ from the current status.
257 * Don't create keys if table is new
259 if (!$is_new_table) {
260 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
261 if (isset($database[$name]["indexes"][$indexname])) {
262 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
264 $current_index_definition = "__NOT_SET__";
266 $new_index_definition = implode(",",$fieldnames);
267 if ($current_index_definition != $new_index_definition) {
268 $sql2=db_create_index($indexname, $fieldnames);
271 $sql3 = "ALTER" . $ignore . " TABLE `".$name."` ".$sql2;
286 if (dbm::is_result($r))
287 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
293 set_config('system', 'maintenance', 0);
298 function db_field_command($parameters, $create = true) {
299 $fieldstruct = $parameters["type"];
301 if ($parameters["not null"])
302 $fieldstruct .= " NOT NULL";
304 if (isset($parameters["default"])){
305 if (strpos(strtolower($parameters["type"]),"int")!==false) {
306 $fieldstruct .= " DEFAULT ".$parameters["default"];
308 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
311 if ($parameters["extra"] != "")
312 $fieldstruct .= " ".$parameters["extra"];
314 /*if (($parameters["primary"] != "") AND $create)
315 $fieldstruct .= " PRIMARY KEY";*/
317 return($fieldstruct);
320 function db_create_table($name, $fields, $charset, $verbose, $action, $indexes=null) {
328 $primary_keys = array();
329 foreach($fields AS $fieldname => $field) {
330 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
331 if (x($field,'primary') and $field['primary']!=''){
332 $primary_keys[] = $fieldname;
336 if (!is_null($indexes)) {
337 foreach ($indexes AS $indexname => $fieldnames) {
338 $sql_index = db_create_index($indexname, $fieldnames, "");
339 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
343 $sql = implode(",\n\t", $sql_rows);
345 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=".$charset;
355 function db_add_table_field($fieldname, $parameters) {
356 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
360 function db_modify_table_field($fieldname, $parameters) {
361 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
365 function db_drop_index($indexname) {
366 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
370 function db_create_index($indexname, $fieldnames, $method="ADD") {
372 $method = strtoupper(trim($method));
373 if ($method!="" && $method!="ADD") {
374 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
378 if ($fieldnames[0] == "UNIQUE") {
379 array_shift($fieldnames);
380 $method .= ' UNIQUE';
384 foreach ($fieldnames AS $fieldname) {
388 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
389 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
391 $names .= "`".dbesc($fieldname)."`";
395 if ($indexname == "PRIMARY") {
396 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
400 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
404 function db_index_suffix($charset, $reduce = 0) {
405 if ($charset != "utf8mb4") {
409 // On utf8mb4 indexes can only have a length of 191
410 $indexlength = 191 - $reduce;
412 return "(".$indexlength.")";
415 function db_definition($charset) {
419 $database["addon"] = array(
421 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
422 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
423 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
424 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
425 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
426 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
427 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
430 "PRIMARY" => array("id"),
433 $database["attach"] = array(
435 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
436 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
437 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
438 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
439 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
440 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
441 "data" => array("type" => "longblob", "not null" => "1"),
442 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
443 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
444 "allow_cid" => array("type" => "mediumtext"),
445 "allow_gid" => array("type" => "mediumtext"),
446 "deny_cid" => array("type" => "mediumtext"),
447 "deny_gid" => array("type" => "mediumtext"),
450 "PRIMARY" => array("id"),
453 $database["auth_codes"] = array(
455 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
456 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
457 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
458 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
459 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
462 "PRIMARY" => array("id"),
465 $database["cache"] = array(
467 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
468 "v" => array("type" => "text"),
469 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
470 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
473 "PRIMARY" => array("k"),
474 "updated" => array("updated"),
475 "expire_mode_updated" => array("expire_mode", "updated"),
478 $database["challenge"] = array(
480 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
481 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
482 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
483 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
484 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
485 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
488 "PRIMARY" => array("id"),
491 $database["clients"] = array(
493 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
494 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
495 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
496 "name" => array("type" => "text"),
497 "icon" => array("type" => "text"),
498 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
501 "PRIMARY" => array("client_id"),
504 $database["config"] = array(
506 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
507 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
508 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
509 "v" => array("type" => "text"),
512 "PRIMARY" => array("id"),
513 "cat_k" => array("UNIQUE", "cat", "k"),
516 $database["contact"] = array(
518 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
519 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
520 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
521 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
522 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
523 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
524 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
525 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
526 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
527 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
528 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
529 "about" => array("type" => "text"),
530 "keywords" => array("type" => "text"),
531 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
532 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
533 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
534 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
535 "photo" => array("type" => "text"),
536 "thumb" => array("type" => "text"),
537 "micro" => array("type" => "text"),
538 "site-pubkey" => array("type" => "text"),
539 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
540 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
541 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
542 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
543 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
544 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
545 "pubkey" => array("type" => "text"),
546 "prvkey" => array("type" => "text"),
547 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
548 "request" => array("type" => "text"),
549 "notify" => array("type" => "text"),
550 "poll" => array("type" => "text"),
551 "confirm" => array("type" => "text"),
552 "poco" => array("type" => "text"),
553 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
554 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
555 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
556 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
557 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
558 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
559 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
560 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
561 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
562 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
563 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
564 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
565 "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
566 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
567 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
568 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
569 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
570 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
571 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
572 "contact-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
573 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
574 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
575 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
576 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
577 "reason" => array("type" => "text"),
578 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
579 "info" => array("type" => "mediumtext"),
580 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
581 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
582 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
583 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
584 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
585 "ffi_keyword_blacklist" => array("type" => "mediumtext"),
588 "PRIMARY" => array("id"),
589 "uid" => array("uid"),
590 "addr_uid" => array("addr(32)", "uid"),
591 "nurl" => array("nurl(32)"),
594 $database["conv"] = array(
596 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
597 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
598 "recips" => array("type" => "mediumtext"),
599 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
600 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
601 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
602 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
603 "subject" => array("type" => "mediumtext"),
606 "PRIMARY" => array("id"),
607 "uid" => array("uid"),
610 $database["deliverq"] = array(
612 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
613 "cmd" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
614 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
615 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
618 "PRIMARY" => array("id"),
619 "cmd_item_contact" => array("UNIQUE", "cmd", "item", "contact"),
622 $database["event"] = array(
624 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
625 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
626 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
627 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
628 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
629 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
630 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
631 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
632 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
633 "summary" => array("type" => "text"),
634 "desc" => array("type" => "text"),
635 "location" => array("type" => "text"),
636 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
637 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
638 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
639 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
640 "allow_cid" => array("type" => "mediumtext"),
641 "allow_gid" => array("type" => "mediumtext"),
642 "deny_cid" => array("type" => "mediumtext"),
643 "deny_gid" => array("type" => "mediumtext"),
646 "PRIMARY" => array("id"),
647 "uid" => array("uid"),
650 $database["fcontact"] = array(
652 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
653 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
654 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
655 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
656 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
657 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
658 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
659 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
660 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
661 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
662 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
663 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
664 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
665 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
666 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
667 "pubkey" => array("type" => "text"),
668 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
671 "PRIMARY" => array("id"),
672 "addr" => array("addr(32)"),
675 $database["ffinder"] = array(
677 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
678 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
679 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
680 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
683 "PRIMARY" => array("id"),
686 $database["fserver"] = array(
688 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
689 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
690 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
691 "key" => array("type" => "text"),
694 "PRIMARY" => array("id"),
695 "server" => array("server(32)"),
698 $database["fsuggest"] = array(
700 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
701 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
702 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
703 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
704 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
705 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
706 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
707 "note" => array("type" => "text"),
708 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
711 "PRIMARY" => array("id"),
714 $database["gcign"] = array(
716 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
717 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
718 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
721 "PRIMARY" => array("id"),
722 "uid" => array("uid"),
723 "gcid" => array("gcid"),
726 $database["gcontact"] = array(
728 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
729 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
731 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
735 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
736 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
737 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
738 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
739 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "about" => array("type" => "text"),
741 "keywords" => array("type" => "text"),
742 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
743 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
744 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
745 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
746 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
747 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
748 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "notify" => array("type" => "text"),
751 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
753 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "PRIMARY" => array("id"),
757 "nurl" => array("nurl(32)"),
758 "name" => array("name(32)"),
759 "nick" => array("nick(32)"),
760 "addr" => array("addr(32)"),
761 "updated" => array("updated"),
764 $database["glink"] = array(
766 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
767 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
768 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
769 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
770 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
771 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
774 "PRIMARY" => array("id"),
775 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
776 "gcid" => array("gcid"),
777 "zcid" => array("zcid"),
780 $database["group"] = array(
782 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
783 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
784 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
785 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
786 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
789 "PRIMARY" => array("id"),
790 "uid" => array("uid"),
793 $database["group_member"] = array(
795 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
796 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
797 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
798 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
801 "PRIMARY" => array("id"),
802 "uid_gid_contactid" => array("uid","gid","contact-id"),
805 $database["gserver"] = array(
807 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
808 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
809 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
810 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
811 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
812 "info" => array("type" => "text"),
813 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
814 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
815 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
816 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
817 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
818 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
819 "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
820 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
821 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
824 "PRIMARY" => array("id"),
825 "nurl" => array("nurl(32)"),
828 $database["hook"] = array(
830 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
831 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
832 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
833 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
834 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
837 "PRIMARY" => array("id"),
838 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
841 $database["intro"] = array(
843 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
844 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
845 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
846 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
847 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
848 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
849 "note" => array("type" => "text"),
850 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
851 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
852 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
853 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
856 "PRIMARY" => array("id"),
859 $database["item"] = array(
861 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
862 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
863 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
864 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
865 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
866 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
867 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
868 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
869 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
870 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
871 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
872 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
873 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
875 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
876 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
877 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
878 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
879 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
880 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
881 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
882 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
883 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
884 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
885 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
886 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888 "body" => array("type" => "mediumtext"),
889 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
892 "object" => array("type" => "text"),
893 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
894 "target" => array("type" => "text"),
895 "postopts" => array("type" => "text"),
896 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
897 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
898 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
899 "tag" => array("type" => "mediumtext"),
900 "attach" => array("type" => "mediumtext"),
901 "inform" => array("type" => "mediumtext"),
902 "file" => array("type" => "mediumtext"),
903 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
904 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
905 "allow_cid" => array("type" => "mediumtext"),
906 "allow_gid" => array("type" => "mediumtext"),
907 "deny_cid" => array("type" => "mediumtext"),
908 "deny_gid" => array("type" => "mediumtext"),
909 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
910 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
911 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
912 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
913 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
914 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
915 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
916 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
917 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
918 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
919 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
920 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
921 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
922 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
923 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
924 "rendered-html" => array("type" => "mediumtext"),
925 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
928 "PRIMARY" => array("id"),
929 "guid" => array("guid"),
930 "uri" => array("uri"),
931 "parent" => array("parent"),
932 "parent-uri" => array("parent-uri"),
933 "extid" => array("extid"),
934 "uid_id" => array("uid","id"),
935 "uid_created" => array("uid","created"),
936 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
937 "uid_network_received" => array("uid","network","received"),
938 "uid_received" => array("uid","received"),
939 "uid_network_commented" => array("uid","network","commented"),
940 // "uid_commented" => array("uid","commented"),
941 "uid_title" => array("uid","title"),
942 "uid_thrparent" => array("uid","thr-parent"),
943 "uid_parenturi" => array("uid","parent-uri"),
944 "uid_contactid_id" => array("uid","contact-id","id"),
945 "uid_contactid_created" => array("uid","contact-id","created"),
946 // "gcontactid_uid_created" => array("gcontact-id","uid","created"),
947 "authorid_created" => array("author-id","created"),
948 // "ownerid_created" => array("owner-id","created"),
949 // "wall_body" => array("wall","body(6)"),
950 // "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
951 "uid_uri" => array("uid", "uri"),
952 "uid_wall_created" => array("uid","wall","created"),
953 "resource-id" => array("resource-id"),
954 "uid_type" => array("uid","type"),
955 // "uid_starred_id" => array("uid","starred", "id"),
956 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
957 // "uid_wall_parent_created" => array("uid","wall","parent","created"),
958 "uid_type_changed" => array("uid","type","changed"),
959 "contactid_verb" => array("contact-id","verb"),
960 "deleted_changed" => array("deleted","changed"),
961 "uid_wall_changed" => array("uid","wall","changed"),
962 "uid_eventid" => array("uid","event-id"),
963 "uid_authorlink" => array("uid","author-link"),
964 "uid_ownerlink" => array("uid","owner-link"),
967 $database["item_id"] = array(
969 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
970 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
971 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
972 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
973 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
976 "PRIMARY" => array("id"),
977 "uid" => array("uid"),
978 "sid" => array("sid"),
979 "service" => array("service(32)"),
980 "iid" => array("iid"),
983 $database["locks"] = array(
985 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
986 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
987 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
988 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
991 "PRIMARY" => array("id"),
994 $database["mail"] = array(
996 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
997 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
998 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
999 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1000 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1001 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1002 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1003 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1004 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1005 "body" => array("type" => "mediumtext"),
1006 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1007 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1008 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1009 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1010 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1011 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1012 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1015 "PRIMARY" => array("id"),
1016 "uid" => array("uid"),
1017 // "guid" => array("guid"),
1018 "convid" => array("convid"),
1019 // "reply" => array("reply"),
1020 "uri" => array("uri"),
1021 "parent-uri" => array("parent-uri(64)"),
1024 $database["mailacct"] = array(
1026 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1027 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1028 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1029 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1030 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1031 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1032 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1033 "pass" => array("type" => "text"),
1034 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1036 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1037 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1038 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1041 "PRIMARY" => array("id"),
1044 $database["manage"] = array(
1046 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1047 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1048 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1051 "PRIMARY" => array("id"),
1052 "uid_mid" => array("uid","mid"),
1055 $database["notify"] = array(
1057 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1058 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1059 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1060 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1061 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1062 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1063 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1064 "msg" => array("type" => "mediumtext"),
1065 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1066 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1067 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1068 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1069 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1070 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1071 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1072 "name_cache" => array("type" => "tinytext"),
1073 "msg_cache" => array("type" => "mediumtext")
1076 "PRIMARY" => array("id"),
1077 "uid_hash" => array("uid", "hash"),
1078 "uid_seen" => array("uid", "seen"),
1079 "uid_type_link" => array("uid", "type", "link"),
1080 "uid_link" => array("uid", "link"),
1083 $database["notify-threads"] = array(
1085 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1086 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1087 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1088 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1089 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1092 "PRIMARY" => array("id"),
1093 "master-parent-item" => array("master-parent-item"),
1094 // "receiver-uid" => array("receiver-uid"),
1097 $database["oembed"] = array(
1099 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1100 "content" => array("type" => "text"),
1101 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1104 "PRIMARY" => array("url"),
1105 "created" => array("created"),
1108 $database["parsed_url"] = array(
1110 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1111 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1112 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1113 "content" => array("type" => "text"),
1114 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1117 "PRIMARY" => array("url", "guessing", "oembed"),
1118 "created" => array("created"),
1121 $database["pconfig"] = array(
1123 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1124 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1125 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1126 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1127 "v" => array("type" => "mediumtext"),
1130 "PRIMARY" => array("id"),
1131 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1134 $database["photo"] = array(
1136 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1137 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1138 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1139 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1140 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1141 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1142 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1143 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1144 "desc" => array("type" => "text"),
1145 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1146 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1147 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1148 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1149 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1150 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1151 "data" => array("type" => "mediumblob", "not null" => "1"),
1152 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1153 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1154 "allow_cid" => array("type" => "mediumtext"),
1155 "allow_gid" => array("type" => "mediumtext"),
1156 "deny_cid" => array("type" => "mediumtext"),
1157 "deny_gid" => array("type" => "mediumtext"),
1160 "PRIMARY" => array("id"),
1161 "uid_contactid" => array("uid", "contact-id"),
1162 "uid_profile" => array("uid", "profile"),
1163 "uid_album_created" => array("uid", "album(32)", "created"),
1164 "resource-id" => array("resource-id(64)"),
1165 // "guid" => array("guid"),
1168 $database["poll"] = array(
1170 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1171 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1172 "q0" => array("type" => "mediumtext"),
1173 "q1" => array("type" => "mediumtext"),
1174 "q2" => array("type" => "mediumtext"),
1175 "q3" => array("type" => "mediumtext"),
1176 "q4" => array("type" => "mediumtext"),
1177 "q5" => array("type" => "mediumtext"),
1178 "q6" => array("type" => "mediumtext"),
1179 "q7" => array("type" => "mediumtext"),
1180 "q8" => array("type" => "mediumtext"),
1181 "q9" => array("type" => "mediumtext"),
1184 "PRIMARY" => array("id"),
1185 "uid" => array("uid"),
1188 $database["poll_result"] = array(
1190 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1191 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1192 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1195 "PRIMARY" => array("id"),
1196 "poll_id" => array("poll_id"),
1197 "choice" => array("choice"),
1200 $database["process"] = array(
1202 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1203 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1204 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1207 "PRIMARY" => array("pid"),
1208 "command" => array("command"),
1211 $database["profile"] = array(
1213 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1214 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1215 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1216 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1217 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1218 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1219 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1220 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1221 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1222 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1223 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1224 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1225 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1226 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1227 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1228 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1229 "with" => array("type" => "text"),
1230 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1231 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1232 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1233 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1234 "pub_keywords" => array("type" => "text"),
1235 "prv_keywords" => array("type" => "text"),
1236 "likes" => array("type" => "text"),
1237 "dislikes" => array("type" => "text"),
1238 "about" => array("type" => "text"),
1239 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1240 "music" => array("type" => "text"),
1241 "book" => array("type" => "text"),
1242 "tv" => array("type" => "text"),
1243 "film" => array("type" => "text"),
1244 "interest" => array("type" => "text"),
1245 "romance" => array("type" => "text"),
1246 "work" => array("type" => "text"),
1247 "education" => array("type" => "text"),
1248 "contact" => array("type" => "text"),
1249 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1250 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1251 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1252 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1253 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1254 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1257 "PRIMARY" => array("id"),
1258 // "hometown" => array("hometown(32)"),
1261 $database["profile_check"] = array(
1263 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1264 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1265 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1266 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1267 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1268 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1271 "PRIMARY" => array("id"),
1274 $database["push_subscriber"] = array(
1276 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1277 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1278 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1279 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1280 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1281 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1282 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1283 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1286 "PRIMARY" => array("id"),
1289 $database["queue"] = array(
1291 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1292 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1293 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1294 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1295 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1296 "content" => array("type" => "mediumtext"),
1297 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1300 "PRIMARY" => array("id"),
1301 "cid" => array("cid"),
1302 "created" => array("created"),
1303 "last" => array("last"),
1304 "network" => array("network"),
1305 "batch" => array("batch"),
1308 $database["register"] = array(
1310 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1311 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1312 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1313 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1314 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1315 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1316 "note" => array("type" => "text"),
1319 "PRIMARY" => array("id"),
1322 $database["search"] = array(
1324 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1325 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1326 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1329 "PRIMARY" => array("id"),
1330 "uid" => array("uid"),
1331 // "term" => array("term(32)"),
1334 $database["session"] = array(
1336 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1337 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1338 "data" => array("type" => "text"),
1339 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1342 "PRIMARY" => array("id"),
1343 "sid" => array("sid(64)"),
1344 "expire" => array("expire"),
1347 $database["sign"] = array(
1349 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1350 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1351 "signed_text" => array("type" => "mediumtext"),
1352 "signature" => array("type" => "text"),
1353 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1356 "PRIMARY" => array("id"),
1357 "iid" => array("iid"),
1360 $database["spam"] = array(
1362 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1363 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1364 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1365 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1366 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1367 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1370 "PRIMARY" => array("id"),
1371 "uid" => array("uid"),
1372 "spam" => array("spam"),
1373 "ham" => array("ham"),
1374 "term" => array("term"),
1377 $database["term"] = array(
1379 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1380 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1381 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1382 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1383 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1384 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1385 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1386 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1387 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1388 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1389 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1390 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1393 "PRIMARY" => array("tid"),
1394 "oid_otype_type_term" => array("oid","otype","type","term"),
1395 "uid_term_tid" => array("uid","term(32)","tid"),
1396 "type_term" => array("type","term(32)"),
1397 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1398 // "otype_type_term_tid" => array("otype","type","term","tid"),
1399 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1400 "guid" => array("guid(64)"),
1403 $database["thread"] = array(
1405 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1406 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1407 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1408 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1409 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1410 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1411 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1412 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1413 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1414 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1415 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1416 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1417 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1418 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1419 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1420 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1421 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1422 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1423 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1424 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1425 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1426 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1427 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1428 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1429 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1430 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1433 "PRIMARY" => array("iid"),
1434 "created" => array("created"),
1435 "commented" => array("commented"),
1436 "uid_network_commented" => array("uid","network","commented"),
1437 "uid_network_created" => array("uid","network","created"),
1438 "uid_contactid_commented" => array("uid","contact-id","commented"),
1439 "uid_contactid_created" => array("uid","contact-id","created"),
1440 // "uid_gcontactid_commented" => array("uid","gcontact-id","commented"),
1441 // "uid_gcontactid_created" => array("uid","gcontact-id","created"),
1442 // "wall_private_received" => array("wall","private","received"),
1443 "uid_created" => array("uid","created"),
1444 "uid_commented" => array("uid","commented"),
1447 $database["tokens"] = array(
1449 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1450 "secret" => array("type" => "text"),
1451 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1452 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1453 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1454 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1457 "PRIMARY" => array("id"),
1460 $database["user"] = array(
1462 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1463 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1464 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1465 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1466 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1467 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1468 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1469 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1470 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1471 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1472 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1473 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1474 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1475 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1476 "pubkey" => array("type" => "text"),
1477 "prvkey" => array("type" => "text"),
1478 "spubkey" => array("type" => "text"),
1479 "sprvkey" => array("type" => "text"),
1480 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1481 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1482 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1483 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1484 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1485 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1486 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1487 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1488 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1489 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1490 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1491 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1492 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1493 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1494 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1495 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1496 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1497 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1498 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1499 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1500 "allow_cid" => array("type" => "mediumtext"),
1501 "allow_gid" => array("type" => "mediumtext"),
1502 "deny_cid" => array("type" => "mediumtext"),
1503 "deny_gid" => array("type" => "mediumtext"),
1504 "openidserver" => array("type" => "text"),
1507 "PRIMARY" => array("uid"),
1508 "nickname" => array("nickname(32)"),
1511 $database["userd"] = array(
1513 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1514 "username" => array("type" => "varchar(255)", "not null" => "1"),
1517 "PRIMARY" => array("id"),
1518 "username" => array("username(32)"),
1521 $database["workerqueue"] = array(
1523 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1524 "parameter" => array("type" => "text"),
1525 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1526 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1527 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1528 "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1531 "PRIMARY" => array("id"),
1532 "created" => array("created"),
1541 * run from command line
1543 function dbstructure_run(&$argv, &$argc) {
1551 @include(".htconfig.php");
1552 require_once("include/dba.php");
1553 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1554 unset($db_host, $db_user, $db_pass, $db_data);
1560 update_structure(true, false);
1563 update_structure(true, true);
1565 $build = get_config('system','build');
1567 set_config('system','build',DB_UPDATE_VERSION);
1568 $build = DB_UPDATE_VERSION;
1571 $stored = intval($build);
1572 $current = intval(DB_UPDATE_VERSION);
1574 // run any left update_nnnn functions in update.php
1575 for($x = $stored; $x < $current; $x ++) {
1576 $r = run_update_function($x);
1580 set_config('system','build',DB_UPDATE_VERSION);
1583 // For the dump that is used to create the database.sql we always assume utfmb4
1584 $charset = "utf8mb4";
1585 print_structure(db_definition($charset), $charset);
1592 echo $argv[0]." <command>\n";
1595 echo "dryrun show database update schema queries without running them\n";
1596 echo "update update database schema\n";
1597 echo "dumpsql dump database schema\n";
1602 if (array_search(__file__,get_included_files())===0){
1603 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);