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 "uid_batch" => array("uid", "batch(64)"),
591 "uid_network" => array("uid", "network"),
592 "addr_uid" => array("addr(32)", "uid"),
593 "nurl_uid" => array("nurl(32)", "uid"),
594 "nick_uid" => array("nick(32)", "uid"),
597 $database["conv"] = array(
599 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
600 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
601 "recips" => array("type" => "mediumtext"),
602 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
603 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
604 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
605 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
606 "subject" => array("type" => "mediumtext"),
609 "PRIMARY" => array("id"),
610 "uid" => array("uid"),
613 $database["deliverq"] = array(
615 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
616 "cmd" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
617 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
618 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
621 "PRIMARY" => array("id"),
622 "cmd_item_contact" => array("UNIQUE", "cmd", "item", "contact"),
625 $database["event"] = array(
627 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
628 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
629 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
630 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
631 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
633 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
634 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
635 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
636 "summary" => array("type" => "text"),
637 "desc" => array("type" => "text"),
638 "location" => array("type" => "text"),
639 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
640 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
641 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
642 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
643 "allow_cid" => array("type" => "mediumtext"),
644 "allow_gid" => array("type" => "mediumtext"),
645 "deny_cid" => array("type" => "mediumtext"),
646 "deny_gid" => array("type" => "mediumtext"),
649 "PRIMARY" => array("id"),
650 "uid" => array("uid"),
653 $database["fcontact"] = array(
655 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
656 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
657 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
658 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
659 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
660 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
661 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
662 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
663 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
664 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
665 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
666 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
667 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
668 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
669 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
670 "pubkey" => array("type" => "text"),
671 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
674 "PRIMARY" => array("id"),
675 "addr" => array("addr(32)"),
678 $database["ffinder"] = array(
680 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
681 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
682 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
683 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
686 "PRIMARY" => array("id"),
689 $database["fserver"] = array(
691 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
692 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
693 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
694 "key" => array("type" => "text"),
697 "PRIMARY" => array("id"),
698 "server" => array("server(32)"),
701 $database["fsuggest"] = array(
703 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
704 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
705 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
706 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
707 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
708 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
709 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
710 "note" => array("type" => "text"),
711 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
714 "PRIMARY" => array("id"),
717 $database["gcign"] = array(
719 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
720 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
721 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
724 "PRIMARY" => array("id"),
725 "uid" => array("uid"),
726 "gcid" => array("gcid"),
729 $database["gcontact"] = array(
731 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
732 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
735 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
739 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
740 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
741 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
742 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "about" => array("type" => "text"),
744 "keywords" => array("type" => "text"),
745 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
746 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
747 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
748 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
749 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
750 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
751 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
753 "notify" => array("type" => "text"),
754 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
756 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "PRIMARY" => array("id"),
760 "nurl" => array("nurl(32)"),
761 "name" => array("name(32)"),
762 "nick" => array("nick(32)"),
763 "addr" => array("addr(32)"),
764 "updated" => array("updated"),
767 $database["glink"] = array(
769 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
770 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
771 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
772 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
773 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
774 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
777 "PRIMARY" => array("id"),
778 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
779 "gcid" => array("gcid"),
780 "zcid" => array("zcid"),
783 $database["group"] = array(
785 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
786 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
787 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
792 "PRIMARY" => array("id"),
793 "uid" => array("uid"),
796 $database["group_member"] = array(
798 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
799 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
800 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
801 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
804 "PRIMARY" => array("id"),
805 "uid_gid_contactid" => array("uid","gid","contact-id"),
808 $database["gserver"] = array(
810 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
811 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
812 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
813 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
814 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
815 "info" => array("type" => "text"),
816 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
817 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
818 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
819 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
820 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
821 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
822 "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
823 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
824 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
827 "PRIMARY" => array("id"),
828 "nurl" => array("nurl(32)"),
831 $database["hook"] = array(
833 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
834 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
835 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
836 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
837 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
840 "PRIMARY" => array("id"),
841 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
844 $database["intro"] = array(
846 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
847 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
848 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
849 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
850 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
851 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
852 "note" => array("type" => "text"),
853 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
854 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
855 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
856 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
859 "PRIMARY" => array("id"),
862 $database["item"] = array(
864 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
865 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
866 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
867 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
868 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
869 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
870 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
872 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
873 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
874 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
875 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
877 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
878 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
879 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
880 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
881 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
882 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
883 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
885 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
886 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
887 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
888 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
889 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "body" => array("type" => "mediumtext"),
892 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
893 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
894 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
895 "object" => array("type" => "text"),
896 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
897 "target" => array("type" => "text"),
898 "postopts" => array("type" => "text"),
899 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
902 "tag" => array("type" => "mediumtext"),
903 "attach" => array("type" => "mediumtext"),
904 "inform" => array("type" => "mediumtext"),
905 "file" => array("type" => "mediumtext"),
906 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
907 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
908 "allow_cid" => array("type" => "mediumtext"),
909 "allow_gid" => array("type" => "mediumtext"),
910 "deny_cid" => array("type" => "mediumtext"),
911 "deny_gid" => array("type" => "mediumtext"),
912 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
913 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
914 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
915 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
916 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
917 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
918 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
919 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
920 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
921 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
922 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
923 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
924 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
925 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
926 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
927 "rendered-html" => array("type" => "mediumtext"),
928 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
931 "PRIMARY" => array("id"),
932 "guid" => array("guid"),
933 "uri" => array("uri"),
934 "parent" => array("parent"),
935 "parent-uri" => array("parent-uri"),
936 "extid" => array("extid"),
937 "uid_id" => array("uid","id"),
938 "uid_created" => array("uid","created"),
939 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
940 "uid_network_received" => array("uid","network","received"),
941 "uid_received" => array("uid","received"),
942 "uid_network_commented" => array("uid","network","commented"),
943 // "uid_commented" => array("uid","commented"),
944 "uid_title" => array("uid","title"),
945 "uid_thrparent" => array("uid","thr-parent"),
946 "uid_parenturi" => array("uid","parent-uri"),
947 "uid_contactid_id" => array("uid","contact-id","id"),
948 "uid_contactid_created" => array("uid","contact-id","created"),
949 // "gcontactid_uid_created" => array("gcontact-id","uid","created"),
950 "authorid_created" => array("author-id","created"),
951 // "ownerid_created" => array("owner-id","created"),
952 // "wall_body" => array("wall","body(6)"),
953 // "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
954 "uid_uri" => array("uid", "uri"),
955 "uid_wall_created" => array("uid","wall","created"),
956 "resource-id" => array("resource-id"),
957 "uid_type" => array("uid","type"),
958 // "uid_starred_id" => array("uid","starred", "id"),
959 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
960 // "uid_wall_parent_created" => array("uid","wall","parent","created"),
961 "uid_type_changed" => array("uid","type","changed"),
962 "contactid_verb" => array("contact-id","verb"),
963 "deleted_changed" => array("deleted","changed"),
964 "uid_wall_changed" => array("uid","wall","changed"),
965 "uid_eventid" => array("uid","event-id"),
966 "uid_authorlink" => array("uid","author-link"),
967 "uid_ownerlink" => array("uid","owner-link"),
970 $database["item_id"] = array(
972 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
973 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
974 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
975 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
976 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
979 "PRIMARY" => array("id"),
980 "uid" => array("uid"),
981 "sid" => array("sid"),
982 "service" => array("service(32)"),
983 "iid" => array("iid"),
986 $database["locks"] = array(
988 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
989 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
990 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
991 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
994 "PRIMARY" => array("id"),
997 $database["mail"] = array(
999 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1000 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1001 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1002 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1003 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1004 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1005 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1006 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1007 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1008 "body" => array("type" => "mediumtext"),
1009 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1010 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1011 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1012 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1013 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1014 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1015 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1018 "PRIMARY" => array("id"),
1019 "uid" => array("uid"),
1020 // "guid" => array("guid"),
1021 "convid" => array("convid"),
1022 // "reply" => array("reply"),
1023 "uri" => array("uri"),
1024 "parent-uri" => array("parent-uri(64)"),
1027 $database["mailacct"] = array(
1029 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1030 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1031 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1032 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1033 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1034 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1036 "pass" => array("type" => "text"),
1037 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1039 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1040 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1041 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1044 "PRIMARY" => array("id"),
1047 $database["manage"] = array(
1049 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1050 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1051 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1054 "PRIMARY" => array("id"),
1055 "uid_mid" => array("uid","mid"),
1058 $database["notify"] = array(
1060 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1061 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1062 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1063 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1064 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1065 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1066 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1067 "msg" => array("type" => "mediumtext"),
1068 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1069 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1070 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1071 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1072 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1073 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1074 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1075 "name_cache" => array("type" => "tinytext"),
1076 "msg_cache" => array("type" => "mediumtext")
1079 "PRIMARY" => array("id"),
1080 "uid_hash" => array("uid", "hash"),
1081 "uid_seen_date" => array("uid", "seen", "date"),
1082 "uid_type_link" => array("uid", "type", "link"),
1083 "uid_link" => array("uid", "link"),
1084 "uid_date" => array("uid", "date"),
1087 $database["notify-threads"] = array(
1089 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1090 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1091 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1092 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1093 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1096 "PRIMARY" => array("id"),
1097 "master-parent-item" => array("master-parent-item"),
1098 // "receiver-uid" => array("receiver-uid"),
1101 $database["oembed"] = array(
1103 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1104 "content" => array("type" => "text"),
1105 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1108 "PRIMARY" => array("url"),
1109 "created" => array("created"),
1112 $database["parsed_url"] = array(
1114 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1115 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1116 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1117 "content" => array("type" => "text"),
1118 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1121 "PRIMARY" => array("url", "guessing", "oembed"),
1122 "created" => array("created"),
1125 $database["pconfig"] = array(
1127 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1128 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1129 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1130 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1131 "v" => array("type" => "mediumtext"),
1134 "PRIMARY" => array("id"),
1135 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1138 $database["photo"] = array(
1140 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1141 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1142 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1143 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1144 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1145 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1146 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1147 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1148 "desc" => array("type" => "text"),
1149 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1150 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1151 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1152 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1153 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1154 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1155 "data" => array("type" => "mediumblob", "not null" => "1"),
1156 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1157 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1158 "allow_cid" => array("type" => "mediumtext"),
1159 "allow_gid" => array("type" => "mediumtext"),
1160 "deny_cid" => array("type" => "mediumtext"),
1161 "deny_gid" => array("type" => "mediumtext"),
1164 "PRIMARY" => array("id"),
1165 "uid_contactid" => array("uid", "contact-id"),
1166 "uid_profile" => array("uid", "profile"),
1167 "uid_album_created" => array("uid", "album(32)", "created"),
1168 "resource-id" => array("resource-id(64)"),
1169 // "guid" => array("guid"),
1172 $database["poll"] = array(
1174 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1175 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1176 "q0" => array("type" => "mediumtext"),
1177 "q1" => array("type" => "mediumtext"),
1178 "q2" => array("type" => "mediumtext"),
1179 "q3" => array("type" => "mediumtext"),
1180 "q4" => array("type" => "mediumtext"),
1181 "q5" => array("type" => "mediumtext"),
1182 "q6" => array("type" => "mediumtext"),
1183 "q7" => array("type" => "mediumtext"),
1184 "q8" => array("type" => "mediumtext"),
1185 "q9" => array("type" => "mediumtext"),
1188 "PRIMARY" => array("id"),
1189 "uid" => array("uid"),
1192 $database["poll_result"] = array(
1194 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1195 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1196 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1199 "PRIMARY" => array("id"),
1200 "poll_id" => array("poll_id"),
1201 "choice" => array("choice"),
1204 $database["process"] = array(
1206 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1207 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1208 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1211 "PRIMARY" => array("pid"),
1212 "command" => array("command"),
1215 $database["profile"] = array(
1217 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1218 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1219 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1220 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1221 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1222 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1223 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1224 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1225 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1226 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1227 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1228 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1229 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1230 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1231 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1232 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1233 "with" => array("type" => "text"),
1234 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1235 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1236 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1237 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1238 "pub_keywords" => array("type" => "text"),
1239 "prv_keywords" => array("type" => "text"),
1240 "likes" => array("type" => "text"),
1241 "dislikes" => array("type" => "text"),
1242 "about" => array("type" => "text"),
1243 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1244 "music" => array("type" => "text"),
1245 "book" => array("type" => "text"),
1246 "tv" => array("type" => "text"),
1247 "film" => array("type" => "text"),
1248 "interest" => array("type" => "text"),
1249 "romance" => array("type" => "text"),
1250 "work" => array("type" => "text"),
1251 "education" => array("type" => "text"),
1252 "contact" => array("type" => "text"),
1253 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1254 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1255 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1256 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1257 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1258 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1261 "PRIMARY" => array("id"),
1262 // "hometown" => array("hometown(32)"),
1265 $database["profile_check"] = array(
1267 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1268 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1269 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1270 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1271 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1272 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1275 "PRIMARY" => array("id"),
1278 $database["push_subscriber"] = array(
1280 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1281 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1282 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1283 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1284 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1285 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1286 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1287 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1290 "PRIMARY" => array("id"),
1293 $database["queue"] = array(
1295 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1296 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1297 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1298 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1299 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1300 "content" => array("type" => "mediumtext"),
1301 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1304 "PRIMARY" => array("id"),
1305 "cid" => array("cid"),
1306 "created" => array("created"),
1307 "last" => array("last"),
1308 "network" => array("network"),
1309 "batch" => array("batch"),
1312 $database["register"] = array(
1314 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1315 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1316 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1317 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1318 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1319 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1320 "note" => array("type" => "text"),
1323 "PRIMARY" => array("id"),
1326 $database["search"] = array(
1328 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1329 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1330 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1333 "PRIMARY" => array("id"),
1334 "uid" => array("uid"),
1335 // "term" => array("term(32)"),
1338 $database["session"] = array(
1340 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1341 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1342 "data" => array("type" => "text"),
1343 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1346 "PRIMARY" => array("id"),
1347 "sid" => array("sid(64)"),
1348 "expire" => array("expire"),
1351 $database["sign"] = array(
1353 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1354 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1355 "signed_text" => array("type" => "mediumtext"),
1356 "signature" => array("type" => "text"),
1357 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1360 "PRIMARY" => array("id"),
1361 "iid" => array("iid"),
1364 $database["spam"] = array(
1366 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1367 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1368 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1369 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1370 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1371 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1374 "PRIMARY" => array("id"),
1375 "uid" => array("uid"),
1376 "spam" => array("spam"),
1377 "ham" => array("ham"),
1378 "term" => array("term"),
1381 $database["term"] = array(
1383 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1384 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1385 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1386 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1387 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1388 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1389 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1390 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1391 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1392 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1393 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1394 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1397 "PRIMARY" => array("tid"),
1398 "oid_otype_type_term" => array("oid","otype","type","term"),
1399 "uid_term_tid" => array("uid","term(32)","tid"),
1400 "type_term" => array("type","term(32)"),
1401 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1402 // "otype_type_term_tid" => array("otype","type","term","tid"),
1403 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1404 "guid" => array("guid(64)"),
1407 $database["thread"] = array(
1409 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1410 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1411 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1412 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1413 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1414 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1415 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1416 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1417 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1418 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1419 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1420 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1421 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1422 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1423 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1424 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1425 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1426 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1427 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1428 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1429 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1430 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1431 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1432 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1433 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1434 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1437 "PRIMARY" => array("iid"),
1438 "created" => array("created"),
1439 "commented" => array("commented"),
1440 "uid_network_commented" => array("uid","network","commented"),
1441 "uid_network_created" => array("uid","network","created"),
1442 "uid_contactid_commented" => array("uid","contact-id","commented"),
1443 "uid_contactid_created" => array("uid","contact-id","created"),
1444 // "uid_gcontactid_commented" => array("uid","gcontact-id","commented"),
1445 // "uid_gcontactid_created" => array("uid","gcontact-id","created"),
1446 // "wall_private_received" => array("wall","private","received"),
1447 "uid_created" => array("uid","created"),
1448 "uid_commented" => array("uid","commented"),
1451 $database["tokens"] = array(
1453 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1454 "secret" => array("type" => "text"),
1455 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1456 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1457 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1458 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1461 "PRIMARY" => array("id"),
1464 $database["user"] = array(
1466 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1467 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1468 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1469 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1470 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1471 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1472 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1473 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1474 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1475 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1476 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1477 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1478 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1479 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1480 "pubkey" => array("type" => "text"),
1481 "prvkey" => array("type" => "text"),
1482 "spubkey" => array("type" => "text"),
1483 "sprvkey" => array("type" => "text"),
1484 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1485 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1486 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1487 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1488 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1489 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1490 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1491 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1492 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1493 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1494 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1495 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1496 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1497 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1498 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1499 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1500 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1501 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1502 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1503 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1504 "allow_cid" => array("type" => "mediumtext"),
1505 "allow_gid" => array("type" => "mediumtext"),
1506 "deny_cid" => array("type" => "mediumtext"),
1507 "deny_gid" => array("type" => "mediumtext"),
1508 "openidserver" => array("type" => "text"),
1511 "PRIMARY" => array("uid"),
1512 "nickname" => array("nickname(32)"),
1515 $database["userd"] = array(
1517 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1518 "username" => array("type" => "varchar(255)", "not null" => "1"),
1521 "PRIMARY" => array("id"),
1522 "username" => array("username(32)"),
1525 $database["workerqueue"] = array(
1527 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1528 "parameter" => array("type" => "text"),
1529 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1530 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1531 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1532 "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1535 "PRIMARY" => array("id"),
1536 "created" => array("created"),
1545 * run from command line
1547 function dbstructure_run(&$argv, &$argc) {
1555 @include(".htconfig.php");
1556 require_once("include/dba.php");
1557 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1558 unset($db_host, $db_user, $db_pass, $db_data);
1564 update_structure(true, false);
1567 update_structure(true, true);
1569 $build = get_config('system','build');
1571 set_config('system','build',DB_UPDATE_VERSION);
1572 $build = DB_UPDATE_VERSION;
1575 $stored = intval($build);
1576 $current = intval(DB_UPDATE_VERSION);
1578 // run any left update_nnnn functions in update.php
1579 for($x = $stored; $x < $current; $x ++) {
1580 $r = run_update_function($x);
1584 set_config('system','build',DB_UPDATE_VERSION);
1587 // For the dump that is used to create the database.sql we always assume utfmb4
1588 $charset = "utf8mb4";
1589 print_structure(db_definition($charset), $charset);
1596 echo $argv[0]." <command>\n";
1599 echo "dryrun show database update schema queries without running them\n";
1600 echo "update update database schema\n";
1601 echo "dumpsql dump database schema\n";
1606 if (array_search(__file__,get_included_files())===0){
1607 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);