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)",
20 // every admin could had different language
22 foreach ($adminlist as $admin) {
23 $lang = (($admin['language'])?$admin['language']:'en');
26 $preamble = deindent(t("
27 The friendica developers released update %s recently,
28 but when I tried to install it, something went terribly wrong.
29 This needs to be fixed soon and I can't do it alone. Please contact a
30 friendica developer if you can not help me on your own. My database might be invalid."));
31 $body = t("The error message is\n[pre]%s[/pre]");
32 $preamble = sprintf($preamble, $update_id);
33 $body = sprintf($body, $error_message);
36 'type' => "SYSTEM_EMAIL",
37 'to_email' => $admin['email'],
38 'preamble' => $preamble,
48 $email_tpl = get_intltext_template("update_fail_eml.tpl");
49 $email_msg = replace_macros($email_tpl, array(
50 '$sitename' => $a->config['sitename'],
51 '$siteurl' => $a->get_baseurl(),
52 '$update' => DB_UPDATE_VERSION,
53 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
55 $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
56 require_once('include/email.php');
57 $subject = email_header_encode($subject,'UTF-8');
58 mail($a->config['admin_email'], $subject, $email_msg,
59 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
60 .'Content-type: text/plain; charset=UTF-8'."\n"
61 .'Content-transfer-encoding: 8bit');
64 logger("CRITICAL: Database structure update failed: ".$retval);
68 function table_structure($table) {
69 $structures = q("DESCRIBE `%s`", $table);
71 $indexes = q("SHOW INDEX FROM `%s`", $table);
76 if (is_array($indexes))
77 foreach ($indexes AS $index) {
78 if ($index["Index_type"] == "FULLTEXT")
81 $column = $index["Column_name"];
82 if ($index["Sub_part"] != "")
83 $column .= "(".$index["Sub_part"].")";
85 $indexdata[$index["Key_name"]][] = $column;
88 if (is_array($structures)) {
89 foreach($structures AS $field) {
90 $fielddata[$field["Field"]]["type"] = $field["Type"];
91 if ($field["Null"] == "NO")
92 $fielddata[$field["Field"]]["not null"] = true;
94 if (isset($field["Default"]))
95 $fielddata[$field["Field"]]["default"] = $field["Default"];
97 if ($field["Extra"] != "")
98 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
100 if ($field["Key"] == "PRI")
101 $fielddata[$field["Field"]]["primary"] = true;
104 return(array("fields"=>$fielddata, "indexes"=>$indexdata));
107 function print_structure($database) {
108 echo "-- ------------------------------------------\n";
109 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
110 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
111 echo "-- ------------------------------------------\n\n\n";
112 foreach ($database AS $name => $structure) {
114 echo "-- TABLE $name\n";
116 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
122 function update_structure($verbose, $action, $tables=null, $definition=null) {
127 logger('updating structure', LOGGER_DEBUG);
129 // Get the current structure
132 if (is_null($tables))
133 $tables = q("show tables");
135 foreach ($tables AS $table) {
136 $table = current($table);
138 $database[$table] = table_structure($table);
141 // Get the definition
142 if (is_null($definition))
143 $definition = db_definition();
147 foreach ($definition AS $name => $structure) {
148 $is_new_table = False;
150 if (!isset($database[$name])) {
151 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
153 $errors .= t('Errors encountered creating database tables.').$name.EOL;
155 $is_new_table = True;
157 // Drop the index if it isn't present in the definition
158 // or the definition differ from current status
159 // and index name doesn't start with "local_"
160 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) {
161 $current_index_definition = implode(",",$fieldnames);
162 if (isset($structure["indexes"][$indexname])) {
163 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
165 $new_index_definition = "__NOT_SET__";
167 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
168 $sql2=db_drop_index($indexname);
170 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
175 // Compare the field structure field by field
176 foreach ($structure["fields"] AS $fieldname => $parameters) {
177 if (!isset($database[$name]["fields"][$fieldname])) {
178 $sql2=db_add_table_field($fieldname, $parameters);
180 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
184 // Compare the field definition
185 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
186 $new_field_definition = implode(",",$parameters);
187 if ($current_field_definition != $new_field_definition) {
188 $sql2=db_modify_table_field($fieldname, $parameters);
190 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
199 // Create the index if the index don't exists in database
200 // or the definition differ from the current status.
201 // Don't create keys if table is new
202 if (!$is_new_table) {
203 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
204 if (isset($database[$name]["indexes"][$indexname])) {
205 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
207 $current_index_definition = "__NOT_SET__";
209 $new_index_definition = implode(",",$fieldnames);
210 if ($current_index_definition != $new_index_definition) {
211 $sql2=db_create_index($indexname, $fieldnames);
214 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
230 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
238 function db_field_command($parameters, $create = true) {
239 $fieldstruct = $parameters["type"];
241 if ($parameters["not null"])
242 $fieldstruct .= " NOT NULL";
244 if (isset($parameters["default"])){
245 if (strpos(strtolower($parameters["type"]),"int")!==false) {
246 $fieldstruct .= " DEFAULT ".$parameters["default"];
248 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
251 if ($parameters["extra"] != "")
252 $fieldstruct .= " ".$parameters["extra"];
254 /*if (($parameters["primary"] != "") AND $create)
255 $fieldstruct .= " PRIMARY KEY";*/
257 return($fieldstruct);
260 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
263 if (isset($a->config["system"]["db_charset"]))
264 $charset = $a->config["system"]["db_charset"];
266 $charset = "utf8mb4";
275 $primary_keys = array();
276 foreach($fields AS $fieldname => $field) {
277 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
278 if (x($field,'primary') and $field['primary']!=''){
279 $primary_keys[] = $fieldname;
283 if (!is_null($indexes)) {
284 foreach ($indexes AS $indexname => $fieldnames) {
285 $sql_index = db_create_index($indexname, $fieldnames, "");
286 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
290 $sql = implode(",\n\t", $sql_rows);
292 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=".$charset;
302 function db_add_table_field($fieldname, $parameters) {
303 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
307 function db_modify_table_field($fieldname, $parameters) {
308 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
312 function db_drop_index($indexname) {
313 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
317 function db_create_index($indexname, $fieldnames, $method="ADD") {
319 $method = strtoupper(trim($method));
320 if ($method!="" && $method!="ADD") {
321 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
326 if ($indexname == "PRIMARY") {
327 return sprintf("%s PRIMARY KEY(`%s`)", $method, implode("`,`", $fieldnames));
331 foreach ($fieldnames AS $fieldname) {
335 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
336 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
338 $names .= "`".dbesc($fieldname)."`";
342 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
346 function db_definition() {
350 $database["addon"] = array(
352 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
353 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
354 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
355 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
356 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
357 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
358 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
361 "PRIMARY" => array("id"),
364 $database["attach"] = array(
366 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
367 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
368 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
369 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
370 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
371 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
372 "data" => array("type" => "longblob", "not null" => "1"),
373 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
374 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
375 "allow_cid" => array("type" => "mediumtext"),
376 "allow_gid" => array("type" => "mediumtext"),
377 "deny_cid" => array("type" => "mediumtext"),
378 "deny_gid" => array("type" => "mediumtext"),
381 "PRIMARY" => array("id"),
384 $database["auth_codes"] = array(
386 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
387 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
388 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
389 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
390 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
393 "PRIMARY" => array("id"),
396 $database["cache"] = array(
398 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
399 "v" => array("type" => "text"),
400 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
401 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
404 "PRIMARY" => array("k"),
405 "updated" => array("updated"),
408 $database["challenge"] = array(
410 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
411 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
412 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
413 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
414 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
415 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
418 "PRIMARY" => array("id"),
421 $database["clients"] = array(
423 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
424 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
425 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
426 "name" => array("type" => "text"),
427 "icon" => array("type" => "text"),
428 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
431 "PRIMARY" => array("client_id"),
434 $database["config"] = array(
436 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
437 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
438 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
439 "v" => array("type" => "text"),
442 "PRIMARY" => array("id"),
443 "cat_k" => array("cat(30)","k(30)"),
446 $database["contact"] = array(
448 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
449 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
450 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
451 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
452 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
453 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
454 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
455 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
456 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
457 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
458 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
459 "about" => array("type" => "text"),
460 "keywords" => array("type" => "text"),
461 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
462 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
463 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
464 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
465 "photo" => array("type" => "text"),
466 "thumb" => array("type" => "text"),
467 "micro" => array("type" => "text"),
468 "site-pubkey" => array("type" => "text"),
469 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
470 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
471 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
472 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
473 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
474 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
475 "pubkey" => array("type" => "text"),
476 "prvkey" => array("type" => "text"),
477 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
478 "request" => array("type" => "text"),
479 "notify" => array("type" => "text"),
480 "poll" => array("type" => "text"),
481 "confirm" => array("type" => "text"),
482 "poco" => array("type" => "text"),
483 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
484 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
485 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
486 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
487 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
488 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
489 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
490 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
491 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
492 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
493 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
494 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
495 "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
496 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
497 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
498 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
499 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
500 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
501 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
502 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
503 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
504 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
505 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
506 "reason" => array("type" => "text"),
507 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
508 "info" => array("type" => "mediumtext"),
509 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
510 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
511 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
512 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
513 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
514 "ffi_keyword_blacklist" => array("type" => "mediumtext"),
517 "PRIMARY" => array("id"),
518 "uid" => array("uid"),
519 "nurl" => array("nurl"),
522 $database["conv"] = array(
524 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
525 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
526 "recips" => array("type" => "mediumtext"),
527 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
528 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
529 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
530 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
531 "subject" => array("type" => "mediumtext"),
534 "PRIMARY" => array("id"),
535 "uid" => array("uid"),
538 $database["deliverq"] = array(
540 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
541 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
542 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
543 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
546 "PRIMARY" => array("id"),
549 $database["event"] = array(
551 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
552 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
553 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
554 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
555 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
556 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
557 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
558 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
559 "summary" => array("type" => "text"),
560 "desc" => array("type" => "text"),
561 "location" => array("type" => "text"),
562 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
563 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
564 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
565 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
566 "allow_cid" => array("type" => "mediumtext"),
567 "allow_gid" => array("type" => "mediumtext"),
568 "deny_cid" => array("type" => "mediumtext"),
569 "deny_gid" => array("type" => "mediumtext"),
572 "PRIMARY" => array("id"),
573 "uid" => array("uid"),
576 $database["fcontact"] = array(
578 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
579 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
580 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
581 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
582 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
583 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
584 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
585 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
586 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
587 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
588 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
589 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
590 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
591 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
592 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
593 "pubkey" => array("type" => "text"),
594 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
597 "PRIMARY" => array("id"),
598 "addr" => array("addr"),
601 $database["ffinder"] = array(
603 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
604 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
605 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
606 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
609 "PRIMARY" => array("id"),
612 $database["fserver"] = array(
614 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
615 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
616 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
617 "key" => array("type" => "text"),
620 "PRIMARY" => array("id"),
621 "server" => array("server"),
624 $database["fsuggest"] = array(
626 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
627 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
628 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
629 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
630 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
631 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
633 "note" => array("type" => "text"),
634 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
637 "PRIMARY" => array("id"),
640 $database["gcign"] = array(
642 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
643 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
644 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
647 "PRIMARY" => array("id"),
648 "uid" => array("uid"),
649 "gcid" => array("gcid"),
652 $database["gcontact"] = array(
654 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
655 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
656 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
657 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
658 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
659 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
660 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
661 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
662 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
663 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
664 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
665 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
666 "about" => array("type" => "text"),
667 "keywords" => array("type" => "text"),
668 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
669 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
670 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
671 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
672 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
673 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
674 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
675 "notify" => array("type" => "text"),
676 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
677 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
678 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
681 "PRIMARY" => array("id"),
682 "nurl" => array("nurl"),
683 "name" => array("name"),
684 "nick" => array("nick"),
685 "addr" => array("addr"),
686 "updated" => array("updated"),
689 $database["glink"] = array(
691 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
692 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
693 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
694 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
695 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
696 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
699 "PRIMARY" => array("id"),
700 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
701 "gcid" => array("gcid"),
702 "zcid" => array("zcid"),
705 $database["group"] = array(
707 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
708 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
709 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
710 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
711 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
714 "PRIMARY" => array("id"),
715 "uid" => array("uid"),
718 $database["group_member"] = array(
720 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
721 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
722 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
723 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
726 "PRIMARY" => array("id"),
727 "uid_gid_contactid" => array("uid","gid","contact-id"),
730 $database["gserver"] = array(
732 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
733 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
735 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "info" => array("type" => "text"),
738 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
739 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
741 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
742 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
744 "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
745 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
746 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
749 "PRIMARY" => array("id"),
750 "nurl" => array("nurl"),
753 $database["hook"] = array(
755 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
756 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
762 "PRIMARY" => array("id"),
763 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
766 $database["intro"] = array(
768 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
769 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
770 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
771 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
772 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "note" => array("type" => "text"),
775 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
776 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
777 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
778 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
781 "PRIMARY" => array("id"),
784 $database["item"] = array(
786 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
787 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
788 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
789 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
790 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
791 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
792 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
793 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
794 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
795 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
796 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
797 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
798 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
799 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
800 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
801 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
802 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
803 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
804 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
805 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
806 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
807 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
808 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
809 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
810 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
811 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
812 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
813 "body" => array("type" => "mediumtext"),
814 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
815 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
816 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
817 "object" => array("type" => "text"),
818 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
819 "target" => array("type" => "text"),
820 "postopts" => array("type" => "text"),
821 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
822 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
823 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
824 "tag" => array("type" => "mediumtext"),
825 "attach" => array("type" => "mediumtext"),
826 "inform" => array("type" => "mediumtext"),
827 "file" => array("type" => "mediumtext"),
828 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
829 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
830 "allow_cid" => array("type" => "mediumtext"),
831 "allow_gid" => array("type" => "mediumtext"),
832 "deny_cid" => array("type" => "mediumtext"),
833 "deny_gid" => array("type" => "mediumtext"),
834 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
835 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
836 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
837 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
838 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
839 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
840 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
841 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
842 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
843 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
844 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
845 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
846 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
847 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
848 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
849 "rendered-html" => array("type" => "mediumtext"),
850 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
853 "PRIMARY" => array("id"),
854 "guid" => array("guid"),
855 "uri" => array("uri"),
856 "parent" => array("parent"),
857 "parent-uri" => array("parent-uri"),
858 "extid" => array("extid"),
859 "uid_id" => array("uid","id"),
860 "uid_created" => array("uid","created"),
861 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
862 "uid_network_received" => array("uid","network","received"),
863 "uid_received" => array("uid","received"),
864 "uid_network_commented" => array("uid","network","commented"),
865 "uid_commented" => array("uid","commented"),
866 "uid_title" => array("uid","title"),
867 "uid_thrparent" => array("uid","thr-parent"),
868 "uid_parenturi" => array("uid","parent-uri"),
869 "uid_contactid_id" => array("uid","contact-id","id"),
870 "uid_contactid_created" => array("uid","contact-id","created"),
871 "gcontactid_uid_created" => array("gcontact-id","uid","created"),
872 "authorid_created" => array("author-id","created"),
873 "ownerid_created" => array("owner-id","created"),
874 "wall_body" => array("wall","body(6)"),
875 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
876 "uid_uri" => array("uid","uri"),
877 "uid_wall_created" => array("uid","wall","created"),
878 "resource-id" => array("resource-id"),
879 "uid_type" => array("uid","type"),
880 "uid_starred_id" => array("uid","starred", "id"),
881 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
882 "uid_wall_parent_created" => array("uid","wall","parent","created"),
883 "uid_type_changed" => array("uid","type","changed"),
884 "contactid_verb" => array("contact-id","verb"),
885 "deleted_changed" => array("deleted","changed"),
886 "uid_wall_changed" => array("uid","wall","changed"),
887 "uid_eventid" => array("uid","event-id"),
888 "uid_authorlink" => array("uid","author-link"),
889 "uid_ownerlink" => array("uid","owner-link"),
892 $database["item_id"] = array(
894 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
895 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
896 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
897 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
898 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "PRIMARY" => array("id"),
902 "uid" => array("uid"),
903 "sid" => array("sid"),
904 "service" => array("service"),
905 "iid" => array("iid"),
908 $database["locks"] = array(
910 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
911 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
912 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
913 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
916 "PRIMARY" => array("id"),
919 $database["mail"] = array(
921 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
922 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
923 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
924 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
925 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
926 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
927 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
928 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
929 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
930 "body" => array("type" => "mediumtext"),
931 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
932 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
933 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
934 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
935 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
936 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
937 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
940 "PRIMARY" => array("id"),
941 "uid" => array("uid"),
942 "guid" => array("guid"),
943 "convid" => array("convid"),
944 "reply" => array("reply"),
945 "uri" => array("uri"),
946 "parent-uri" => array("parent-uri"),
949 $database["mailacct"] = array(
951 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
952 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
953 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
954 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
955 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
956 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
957 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "pass" => array("type" => "text"),
959 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
961 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
963 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
966 "PRIMARY" => array("id"),
969 $database["manage"] = array(
971 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
972 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
973 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
976 "PRIMARY" => array("id"),
977 "uid_mid" => array("uid","mid"),
980 $database["notify"] = array(
982 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
983 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
984 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
985 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
986 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
987 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
988 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
989 "msg" => array("type" => "mediumtext"),
990 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
991 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
992 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
993 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
994 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
995 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
996 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
999 "PRIMARY" => array("id"),
1000 "uid" => array("uid"),
1003 $database["notify-threads"] = array(
1005 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1006 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1007 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1008 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1009 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1012 "PRIMARY" => array("id"),
1013 "master-parent-item" => array("master-parent-item"),
1014 "receiver-uid" => array("receiver-uid"),
1017 $database["oembed"] = array(
1019 "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
1020 "content" => array("type" => "text"),
1021 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1024 "PRIMARY" => array("url"),
1025 "created" => array("created"),
1028 $database["parsed_url"] = array(
1030 "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
1031 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1032 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1033 "content" => array("type" => "text"),
1034 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1037 "PRIMARY" => array("url", "guessing", "oembed"),
1038 "created" => array("created"),
1041 $database["pconfig"] = array(
1043 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1044 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1045 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "v" => array("type" => "mediumtext"),
1050 "PRIMARY" => array("id"),
1051 "uid_cat_k" => array("uid","cat(30)","k(30)"),
1054 $database["photo"] = array(
1056 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1057 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1058 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1059 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1060 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1061 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1062 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1063 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1064 "desc" => array("type" => "text"),
1065 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1066 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1067 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1068 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1069 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1070 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1071 "data" => array("type" => "mediumblob", "not null" => "1"),
1072 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1073 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1074 "allow_cid" => array("type" => "mediumtext"),
1075 "allow_gid" => array("type" => "mediumtext"),
1076 "deny_cid" => array("type" => "mediumtext"),
1077 "deny_gid" => array("type" => "mediumtext"),
1080 "PRIMARY" => array("id"),
1081 "uid" => array("uid"),
1082 "resource-id" => array("resource-id"),
1083 "guid" => array("guid"),
1086 $database["poll"] = array(
1088 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1089 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1090 "q0" => array("type" => "mediumtext"),
1091 "q1" => array("type" => "mediumtext"),
1092 "q2" => array("type" => "mediumtext"),
1093 "q3" => array("type" => "mediumtext"),
1094 "q4" => array("type" => "mediumtext"),
1095 "q5" => array("type" => "mediumtext"),
1096 "q6" => array("type" => "mediumtext"),
1097 "q7" => array("type" => "mediumtext"),
1098 "q8" => array("type" => "mediumtext"),
1099 "q9" => array("type" => "mediumtext"),
1102 "PRIMARY" => array("id"),
1103 "uid" => array("uid"),
1106 $database["poll_result"] = array(
1108 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1109 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1110 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1113 "PRIMARY" => array("id"),
1114 "poll_id" => array("poll_id"),
1115 "choice" => array("choice"),
1118 $database["process"] = array(
1120 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1121 "command" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1122 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1125 "PRIMARY" => array("pid"),
1126 "command" => array("command"),
1129 $database["profile"] = array(
1131 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1132 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1133 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1135 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1136 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1137 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1138 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1139 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1140 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1141 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1142 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1143 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1144 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1145 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1146 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1147 "with" => array("type" => "text"),
1148 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1149 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1150 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1151 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1152 "pub_keywords" => array("type" => "text"),
1153 "prv_keywords" => array("type" => "text"),
1154 "likes" => array("type" => "text"),
1155 "dislikes" => array("type" => "text"),
1156 "about" => array("type" => "text"),
1157 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1158 "music" => array("type" => "text"),
1159 "book" => array("type" => "text"),
1160 "tv" => array("type" => "text"),
1161 "film" => array("type" => "text"),
1162 "interest" => array("type" => "text"),
1163 "romance" => array("type" => "text"),
1164 "work" => array("type" => "text"),
1165 "education" => array("type" => "text"),
1166 "contact" => array("type" => "text"),
1167 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1168 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1169 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1170 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1171 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1172 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1175 "PRIMARY" => array("id"),
1176 "hometown" => array("hometown"),
1179 $database["profile_check"] = array(
1181 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1182 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1183 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1184 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1185 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1186 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1189 "PRIMARY" => array("id"),
1192 $database["push_subscriber"] = array(
1194 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1195 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1196 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1197 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1198 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1199 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1200 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1201 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1204 "PRIMARY" => array("id"),
1207 $database["queue"] = array(
1209 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1210 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1211 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1212 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1213 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1214 "content" => array("type" => "mediumtext"),
1215 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1218 "PRIMARY" => array("id"),
1219 "cid" => array("cid"),
1220 "created" => array("created"),
1221 "last" => array("last"),
1222 "network" => array("network"),
1223 "batch" => array("batch"),
1226 $database["register"] = array(
1228 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1229 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1230 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1231 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1232 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1233 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1236 "PRIMARY" => array("id"),
1239 $database["search"] = array(
1241 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1242 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1243 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1246 "PRIMARY" => array("id"),
1247 "uid" => array("uid"),
1248 "term" => array("term"),
1251 $database["session"] = array(
1253 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1254 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1255 "data" => array("type" => "text"),
1256 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1259 "PRIMARY" => array("id"),
1260 "sid" => array("sid"),
1261 "expire" => array("expire"),
1264 $database["sign"] = array(
1266 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1267 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1268 "signed_text" => array("type" => "mediumtext"),
1269 "signature" => array("type" => "text"),
1270 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1273 "PRIMARY" => array("id"),
1274 "iid" => array("iid"),
1277 $database["spam"] = array(
1279 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1280 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1281 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1282 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1283 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1284 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1287 "PRIMARY" => array("id"),
1288 "uid" => array("uid"),
1289 "spam" => array("spam"),
1290 "ham" => array("ham"),
1291 "term" => array("term"),
1294 $database["term"] = array(
1296 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1297 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1298 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1299 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1300 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1301 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1302 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1303 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1304 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1305 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1306 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1307 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1310 "PRIMARY" => array("tid"),
1311 "oid_otype_type_term" => array("oid","otype","type","term"),
1312 "uid_term_tid" => array("uid","term","tid"),
1313 "type_term" => array("type","term"),
1314 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1315 "otype_type_term_tid" => array("otype","type","term","tid"),
1316 "guid" => array("guid"),
1319 $database["thread"] = array(
1321 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1322 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1323 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1324 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1325 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1326 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1327 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1328 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1329 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1330 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1331 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1332 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1333 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1334 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1335 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1336 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1337 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1338 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1339 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1340 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1341 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1342 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1343 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1344 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1345 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1346 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1349 "PRIMARY" => array("iid"),
1350 "created" => array("created"),
1351 "commented" => array("commented"),
1352 "uid_network_commented" => array("uid","network","commented"),
1353 "uid_network_created" => array("uid","network","created"),
1354 "uid_contactid_commented" => array("uid","contact-id","commented"),
1355 "uid_contactid_created" => array("uid","contact-id","created"),
1356 "uid_gcontactid_commented" => array("uid","gcontact-id","commented"),
1357 "uid_gcontactid_created" => array("uid","gcontact-id","created"),
1358 "wall_private_received" => array("wall","private","received"),
1359 "uid_created" => array("uid","created"),
1360 "uid_commented" => array("uid","commented"),
1363 $database["tokens"] = array(
1365 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1366 "secret" => array("type" => "text"),
1367 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1368 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1369 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1370 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1373 "PRIMARY" => array("id"),
1376 $database["user"] = array(
1378 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1379 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1380 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1381 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1382 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1383 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1384 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1385 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1386 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1387 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1388 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1389 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1390 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1391 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1392 "pubkey" => array("type" => "text"),
1393 "prvkey" => array("type" => "text"),
1394 "spubkey" => array("type" => "text"),
1395 "sprvkey" => array("type" => "text"),
1396 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1397 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1398 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1399 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1400 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1401 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1402 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1403 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1404 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1405 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1406 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1407 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1408 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1409 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1410 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1411 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1412 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1413 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1414 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1415 "allow_cid" => array("type" => "mediumtext"),
1416 "allow_gid" => array("type" => "mediumtext"),
1417 "deny_cid" => array("type" => "mediumtext"),
1418 "deny_gid" => array("type" => "mediumtext"),
1419 "openidserver" => array("type" => "text"),
1422 "PRIMARY" => array("uid"),
1423 "nickname" => array("nickname"),
1426 $database["userd"] = array(
1428 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1429 "username" => array("type" => "varchar(255)", "not null" => "1"),
1432 "PRIMARY" => array("id"),
1433 "username" => array("username"),
1436 $database["workerqueue"] = array(
1438 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1439 "parameter" => array("type" => "text"),
1440 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1441 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1442 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1443 "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1446 "PRIMARY" => array("id"),
1447 "created" => array("created"),
1456 * run from command line
1458 function dbstructure_run(&$argv, &$argc) {
1466 @include(".htconfig.php");
1467 require_once("include/dba.php");
1468 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1469 unset($db_host, $db_user, $db_pass, $db_data);
1475 update_structure(true, true);
1476 set_config('system','build',DB_UPDATE_VERSION);
1479 print_structure(db_definition());
1486 echo $argv[0]." <command>\n";
1489 echo "update update database schema\n";
1490 echo "dumpsql dump database schema\n";
1498 if (array_search(__file__,get_included_files())===0){
1499 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);