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);
69 function table_structure($table) {
70 $structures = q("DESCRIBE `%s`", $table);
72 $indexes = q("SHOW INDEX FROM `%s`", $table);
77 if (is_array($indexes))
78 foreach ($indexes AS $index) {
79 if ($index["Index_type"] == "FULLTEXT")
82 $column = $index["Column_name"];
83 if ($index["Sub_part"] != "")
84 $column .= "(".$index["Sub_part"].")";
86 $indexdata[$index["Key_name"]][] = $column;
89 if (is_array($structures)) {
90 foreach($structures AS $field) {
91 $fielddata[$field["Field"]]["type"] = $field["Type"];
92 if ($field["Null"] == "NO")
93 $fielddata[$field["Field"]]["not null"] = true;
95 if (isset($field["Default"]))
96 $fielddata[$field["Field"]]["default"] = $field["Default"];
98 if ($field["Extra"] != "")
99 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
101 if ($field["Key"] == "PRI")
102 $fielddata[$field["Field"]]["primary"] = true;
105 return(array("fields"=>$fielddata, "indexes"=>$indexdata));
108 function print_structure($database) {
109 echo "-- ------------------------------------------\n";
110 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
111 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
112 echo "-- ------------------------------------------\n\n\n";
113 foreach ($database AS $name => $structure) {
115 echo "-- TABLE $name\n";
117 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
123 function update_structure($verbose, $action, $tables=null, $definition=null) {
128 logger('updating structure', LOGGER_DEBUG);
130 // Get the current structure
133 if (is_null($tables))
134 $tables = q("show tables");
136 foreach ($tables AS $table) {
137 $table = current($table);
139 $database[$table] = table_structure($table);
142 // Get the definition
143 if (is_null($definition))
144 $definition = db_definition();
148 foreach ($definition AS $name => $structure) {
149 $is_new_table = False;
151 if (!isset($database[$name])) {
152 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
154 $errors .= t('Errors encountered creating database tables.').$name.EOL;
156 $is_new_table = True;
158 // Drop the index if it isn't present in the definition
159 // or the definition differ from current status
160 // and index name doesn't start with "local_"
161 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) {
162 $current_index_definition = implode(",",$fieldnames);
163 if (isset($structure["indexes"][$indexname])) {
164 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
166 $new_index_definition = "__NOT_SET__";
168 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
169 $sql2=db_drop_index($indexname);
171 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
176 // Compare the field structure field by field
177 foreach ($structure["fields"] AS $fieldname => $parameters) {
178 if (!isset($database[$name]["fields"][$fieldname])) {
179 $sql2=db_add_table_field($fieldname, $parameters);
181 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
185 // Compare the field definition
186 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
187 $new_field_definition = implode(",",$parameters);
188 if ($current_field_definition != $new_field_definition) {
189 $sql2=db_modify_table_field($fieldname, $parameters);
191 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
200 // Create the index if the index don't exists in database
201 // or the definition differ from the current status.
202 // Don't create keys if table is new
203 if (!$is_new_table) {
204 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
205 if (isset($database[$name]["indexes"][$indexname])) {
206 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
208 $current_index_definition = "__NOT_SET__";
210 $new_index_definition = implode(",",$fieldnames);
211 if ($current_index_definition != $new_index_definition) {
212 $sql2=db_create_index($indexname, $fieldnames);
215 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
231 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
239 function db_field_command($parameters, $create = true) {
240 $fieldstruct = $parameters["type"];
242 if ($parameters["not null"])
243 $fieldstruct .= " NOT NULL";
245 if (isset($parameters["default"])){
246 if (strpos(strtolower($parameters["type"]),"int")!==false) {
247 $fieldstruct .= " DEFAULT ".$parameters["default"];
249 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
252 if ($parameters["extra"] != "")
253 $fieldstruct .= " ".$parameters["extra"];
255 /*if (($parameters["primary"] != "") AND $create)
256 $fieldstruct .= " PRIMARY KEY";*/
258 return($fieldstruct);
261 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
269 $primary_keys = array();
270 foreach($fields AS $fieldname => $field) {
271 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
272 if (x($field,'primary') and $field['primary']!=''){
273 $primary_keys[] = $fieldname;
277 if (!is_null($indexes)) {
278 foreach ($indexes AS $indexname => $fieldnames) {
279 $sql_index = db_create_index($indexname, $fieldnames, "");
280 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
284 $sql = implode(",\n\t", $sql_rows);
286 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
296 function db_add_table_field($fieldname, $parameters) {
297 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
301 function db_modify_table_field($fieldname, $parameters) {
302 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
306 function db_drop_index($indexname) {
307 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
311 function db_create_index($indexname, $fieldnames, $method="ADD") {
313 $method = strtoupper(trim($method));
314 if ($method!="" && $method!="ADD") {
315 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
320 if ($indexname == "PRIMARY") {
321 return sprintf("%s PRIMARY KEY(`%s`)", $method, implode("`,`", $fieldnames));
325 foreach ($fieldnames AS $fieldname) {
329 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
330 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
332 $names .= "`".dbesc($fieldname)."`";
336 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
340 function db_definition() {
344 $database["addon"] = array(
346 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
347 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
348 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
349 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
350 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
351 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
352 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
355 "PRIMARY" => array("id"),
358 $database["attach"] = array(
360 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
361 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
362 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
363 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
364 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
365 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
366 "data" => array("type" => "longblob", "not null" => "1"),
367 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
368 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
369 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
370 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
371 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
372 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
375 "PRIMARY" => array("id"),
378 $database["auth_codes"] = array(
380 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
381 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
382 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
383 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
384 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
387 "PRIMARY" => array("id"),
390 $database["cache"] = array(
392 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
393 "v" => array("type" => "text", "not null" => "1"),
394 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
395 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
398 "PRIMARY" => array("k"),
399 "updated" => array("updated"),
402 $database["challenge"] = array(
404 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
405 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
406 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
407 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
408 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
409 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
412 "PRIMARY" => array("id"),
415 $database["clients"] = array(
417 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
418 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
419 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
420 "name" => array("type" => "text"),
421 "icon" => array("type" => "text"),
422 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
425 "PRIMARY" => array("client_id"),
428 $database["config"] = array(
430 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
431 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
432 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
433 "v" => array("type" => "text", "not null" => "1"),
436 "PRIMARY" => array("id"),
437 "cat_k" => array("cat(30)","k(30)"),
440 $database["contact"] = array(
442 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
443 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
444 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
445 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
446 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
447 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
448 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
449 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
450 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
451 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
452 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
453 "about" => array("type" => "text", "not null" => "1"),
454 "keywords" => array("type" => "text", "not null" => "1"),
455 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
456 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
457 "photo" => array("type" => "text", "not null" => "1"),
458 "thumb" => array("type" => "text", "not null" => "1"),
459 "micro" => array("type" => "text", "not null" => "1"),
460 "site-pubkey" => array("type" => "text", "not null" => "1"),
461 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
462 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
463 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
464 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
465 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
466 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
467 "pubkey" => array("type" => "text", "not null" => "1"),
468 "prvkey" => array("type" => "text", "not null" => "1"),
469 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
470 "request" => array("type" => "text", "not null" => "1"),
471 "notify" => array("type" => "text", "not null" => "1"),
472 "poll" => array("type" => "text", "not null" => "1"),
473 "confirm" => array("type" => "text", "not null" => "1"),
474 "poco" => array("type" => "text", "not null" => "1"),
475 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
476 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
477 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
478 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
479 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
480 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
481 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
482 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
483 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
484 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
485 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
486 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
487 "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
488 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
489 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
490 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
491 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
492 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
493 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
494 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
495 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
496 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
497 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
498 "reason" => array("type" => "text", "not null" => "1"),
499 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
500 "info" => array("type" => "mediumtext", "not null" => "1"),
501 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
502 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
503 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
504 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
505 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
506 "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
509 "PRIMARY" => array("id"),
510 "uid" => array("uid"),
513 $database["conv"] = array(
515 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
516 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
517 "recips" => array("type" => "mediumtext", "not null" => "1"),
518 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
519 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
520 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
521 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
522 "subject" => array("type" => "mediumtext", "not null" => "1"),
525 "PRIMARY" => array("id"),
526 "uid" => array("uid"),
529 $database["deliverq"] = array(
531 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
532 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
533 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
534 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
537 "PRIMARY" => array("id"),
540 $database["dsprphotoq"] = array(
542 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
543 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
544 "msg" => array("type" => "mediumtext", "not null" => "1"),
545 "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
548 "PRIMARY" => array("id"),
551 $database["event"] = array(
553 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
554 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
555 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
556 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
557 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
558 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
559 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
560 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
561 "summary" => array("type" => "text", "not null" => "1"),
562 "desc" => array("type" => "text", "not null" => "1"),
563 "location" => array("type" => "text", "not null" => "1"),
564 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
565 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
566 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
567 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
568 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
569 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
570 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
571 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
574 "PRIMARY" => array("id"),
575 "uid" => array("uid"),
578 $database["fcontact"] = array(
580 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
581 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
582 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
583 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
584 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
585 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
586 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
587 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
588 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
589 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
590 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
591 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
592 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
593 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
594 "pubkey" => array("type" => "text", "not null" => "1"),
595 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
598 "PRIMARY" => array("id"),
599 "addr" => array("addr"),
602 $database["ffinder"] = array(
604 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
605 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
606 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
607 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
610 "PRIMARY" => array("id"),
613 $database["fserver"] = array(
615 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
616 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
617 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
618 "key" => array("type" => "text", "not null" => "1"),
621 "PRIMARY" => array("id"),
622 "server" => array("server"),
625 $database["fsuggest"] = array(
627 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
628 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
629 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
630 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
631 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
633 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
634 "note" => array("type" => "text", "not null" => "1"),
635 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
638 "PRIMARY" => array("id"),
641 $database["gcign"] = array(
643 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
644 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
645 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
648 "PRIMARY" => array("id"),
649 "uid" => array("uid"),
650 "gcid" => array("gcid"),
653 $database["gcontact"] = array(
655 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
656 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
657 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
658 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
659 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
660 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
661 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
662 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
663 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
664 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
665 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
666 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
667 "about" => array("type" => "text", "not null" => "1"),
668 "keywords" => array("type" => "text", "not null" => "1"),
669 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
670 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
671 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
672 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
673 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
674 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
677 "PRIMARY" => array("id"),
678 "nurl" => array("nurl"),
679 "updated" => array("updated"),
682 $database["glink"] = array(
684 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
685 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
686 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
687 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
688 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
689 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
692 "PRIMARY" => array("id"),
693 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
694 "gcid" => array("gcid"),
695 "zcid" => array("zcid"),
698 $database["group"] = array(
700 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
701 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
702 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
703 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
704 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
707 "PRIMARY" => array("id"),
708 "uid" => array("uid"),
711 $database["group_member"] = array(
713 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
714 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
715 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
716 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
719 "PRIMARY" => array("id"),
720 "uid_gid_contactid" => array("uid","gid","contact-id"),
723 $database["gserver"] = array(
725 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
726 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
727 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
728 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
729 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "info" => array("type" => "text", "not null" => "1"),
731 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
732 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
735 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
737 "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
738 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
739 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
742 "PRIMARY" => array("id"),
743 "nurl" => array("nurl"),
746 $database["guid"] = array(
748 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
749 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
751 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
755 "PRIMARY" => array("id"),
756 "guid" => array("guid"),
757 "plink" => array("plink"),
758 "uri" => array("uri"),
761 $database["hook"] = array(
763 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
764 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
765 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
766 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
767 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
770 "PRIMARY" => array("id"),
771 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
774 $database["intro"] = array(
776 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
777 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
778 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
779 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
780 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
781 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782 "note" => array("type" => "text", "not null" => "1"),
783 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
784 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
785 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
786 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "PRIMARY" => array("id"),
792 $database["item"] = array(
794 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
795 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
796 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
797 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
798 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
799 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
800 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
801 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
802 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
803 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
804 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
805 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
806 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
807 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
808 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
809 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
810 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
811 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
812 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
813 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
814 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
815 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
816 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
817 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
818 "body" => array("type" => "mediumtext", "not null" => "1"),
819 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
820 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
821 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
822 "object" => array("type" => "text", "not null" => "1"),
823 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
824 "target" => array("type" => "text", "not null" => "1"),
825 "postopts" => array("type" => "text", "not null" => "1"),
826 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
827 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
828 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
829 "tag" => array("type" => "mediumtext", "not null" => "1"),
830 "attach" => array("type" => "mediumtext", "not null" => "1"),
831 "inform" => array("type" => "mediumtext", "not null" => "1"),
832 "file" => array("type" => "mediumtext", "not null" => "1"),
833 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
834 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
835 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
836 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
837 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
838 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
839 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
840 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
841 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
842 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
843 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
844 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
845 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
846 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
847 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
848 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
849 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
850 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
851 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
852 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
853 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
854 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
855 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
858 "PRIMARY" => array("id"),
859 "guid" => array("guid"),
860 "uri" => array("uri"),
861 "parent" => array("parent"),
862 "parent-uri" => array("parent-uri"),
863 "extid" => array("extid"),
864 "uid_id" => array("uid","id"),
865 "uid_created" => array("uid","created"),
866 "uid_unseen" => array("uid","unseen"),
867 "uid_network_received" => array("uid","network","received"),
868 "uid_received" => array("uid","received"),
869 "uid_network_commented" => array("uid","network","commented"),
870 "uid_commented" => array("uid","commented"),
871 "uid_title" => array("uid","title"),
872 "uid_thrparent" => array("uid","thr-parent"),
873 "uid_parenturi" => array("uid","parent-uri"),
874 "uid_contactid_created" => array("uid","contact-id","created"),
875 "wall_body" => array("wall","body(6)"),
876 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
877 "uid_uri" => array("uid","uri"),
878 "uid_wall_created" => array("uid","wall","created"),
879 "resource-id" => array("resource-id"),
880 "uid_type" => array("uid","type"),
881 "uid_starred" => array("uid","starred"),
882 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
883 "uid_wall_parent_created" => array("uid","wall","parent","created"),
884 "uid_type_changed" => array("uid","type","changed"),
885 "contactid_verb" => array("contact-id","verb"),
886 "deleted_changed" => array("deleted","changed"),
887 "uid_wall_changed" => array("uid","wall","changed"),
888 "uid_eventid" => array("uid","event-id"),
889 "uid_authorlink" => array("uid","author-link"),
890 "uid_ownerlink" => array("uid","owner-link"),
893 $database["item_id"] = array(
895 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
896 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
897 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
898 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
899 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
902 "PRIMARY" => array("id"),
903 "uid" => array("uid"),
904 "sid" => array("sid"),
905 "service" => array("service"),
906 "iid" => array("iid"),
909 $database["locks"] = array(
911 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
912 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
913 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
914 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
917 "PRIMARY" => array("id"),
920 $database["mail"] = array(
922 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
923 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
924 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
925 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
926 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
927 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
928 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
929 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
930 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
931 "body" => array("type" => "mediumtext", "not null" => "1"),
932 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
933 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
934 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
935 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
936 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
937 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
938 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
941 "PRIMARY" => array("id"),
942 "uid" => array("uid"),
943 "guid" => array("guid"),
944 "convid" => array("convid"),
945 "reply" => array("reply"),
946 "uri" => array("uri"),
947 "parent-uri" => array("parent-uri"),
950 $database["mailacct"] = array(
952 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
953 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
954 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
955 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
956 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
957 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "pass" => array("type" => "text", "not null" => "1"),
960 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
962 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
963 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
964 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
967 "PRIMARY" => array("id"),
970 $database["manage"] = array(
972 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
973 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
974 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
977 "PRIMARY" => array("id"),
978 "uid_mid" => array("uid","mid"),
981 $database["notify"] = array(
983 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
984 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
985 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
986 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
987 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
988 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
989 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
990 "msg" => array("type" => "mediumtext", "not null" => "1"),
991 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
992 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
993 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
994 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
995 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
996 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
997 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1000 "PRIMARY" => array("id"),
1001 "uid" => array("uid"),
1004 $database["notify-threads"] = array(
1006 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1007 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1008 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1009 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1010 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1013 "PRIMARY" => array("id"),
1014 "master-parent-item" => array("master-parent-item"),
1015 "receiver-uid" => array("receiver-uid"),
1018 $database["pconfig"] = array(
1020 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1021 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1022 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1024 "v" => array("type" => "mediumtext", "not null" => "1"),
1027 "PRIMARY" => array("id"),
1028 "uid_cat_k" => array("uid","cat(30)","k(30)"),
1031 $database["photo"] = array(
1033 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1034 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1035 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1036 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1037 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1039 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1040 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "desc" => array("type" => "text", "not null" => "1"),
1042 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1045 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1046 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1047 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1048 "data" => array("type" => "mediumblob", "not null" => "1"),
1049 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1050 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1051 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1052 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1053 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1054 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1057 "PRIMARY" => array("id"),
1058 "uid" => array("uid"),
1059 "resource-id" => array("resource-id"),
1060 "guid" => array("guid"),
1063 $database["poll"] = array(
1065 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1066 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1067 "q0" => array("type" => "mediumtext", "not null" => "1"),
1068 "q1" => array("type" => "mediumtext", "not null" => "1"),
1069 "q2" => array("type" => "mediumtext", "not null" => "1"),
1070 "q3" => array("type" => "mediumtext", "not null" => "1"),
1071 "q4" => array("type" => "mediumtext", "not null" => "1"),
1072 "q5" => array("type" => "mediumtext", "not null" => "1"),
1073 "q6" => array("type" => "mediumtext", "not null" => "1"),
1074 "q7" => array("type" => "mediumtext", "not null" => "1"),
1075 "q8" => array("type" => "mediumtext", "not null" => "1"),
1076 "q9" => array("type" => "mediumtext", "not null" => "1"),
1079 "PRIMARY" => array("id"),
1080 "uid" => array("uid"),
1083 $database["poll_result"] = array(
1085 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1086 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1087 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1090 "PRIMARY" => array("id"),
1091 "poll_id" => array("poll_id"),
1092 "choice" => array("choice"),
1095 $database["profile"] = array(
1097 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1098 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1099 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1100 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1101 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1102 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1105 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1107 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1108 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1109 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1110 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1111 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1112 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1113 "with" => array("type" => "text", "not null" => "1"),
1114 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1115 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1118 "pub_keywords" => array("type" => "text", "not null" => "1"),
1119 "prv_keywords" => array("type" => "text", "not null" => "1"),
1120 "likes" => array("type" => "text", "not null" => "1"),
1121 "dislikes" => array("type" => "text", "not null" => "1"),
1122 "about" => array("type" => "text", "not null" => "1"),
1123 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1124 "music" => array("type" => "text", "not null" => "1"),
1125 "book" => array("type" => "text", "not null" => "1"),
1126 "tv" => array("type" => "text", "not null" => "1"),
1127 "film" => array("type" => "text", "not null" => "1"),
1128 "interest" => array("type" => "text", "not null" => "1"),
1129 "romance" => array("type" => "text", "not null" => "1"),
1130 "work" => array("type" => "text", "not null" => "1"),
1131 "education" => array("type" => "text", "not null" => "1"),
1132 "contact" => array("type" => "text", "not null" => "1"),
1133 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1135 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1136 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1137 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1140 "PRIMARY" => array("id"),
1141 "hometown" => array("hometown"),
1144 $database["profile_check"] = array(
1146 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1147 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1148 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1149 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1150 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1151 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1154 "PRIMARY" => array("id"),
1157 $database["push_subscriber"] = array(
1159 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1160 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1161 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1162 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1163 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1164 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1165 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1166 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1169 "PRIMARY" => array("id"),
1172 $database["queue"] = array(
1174 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1175 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1176 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1177 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1178 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1179 "content" => array("type" => "mediumtext", "not null" => "1"),
1180 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1183 "PRIMARY" => array("id"),
1184 "cid" => array("cid"),
1185 "created" => array("created"),
1186 "last" => array("last"),
1187 "network" => array("network"),
1188 "batch" => array("batch"),
1191 $database["register"] = array(
1193 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1194 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1195 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1196 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1197 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1198 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1201 "PRIMARY" => array("id"),
1204 $database["search"] = array(
1206 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1207 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1208 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1211 "PRIMARY" => array("id"),
1212 "uid" => array("uid"),
1213 "term" => array("term"),
1216 $database["session"] = array(
1218 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1219 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1220 "data" => array("type" => "text", "not null" => "1"),
1221 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1224 "PRIMARY" => array("id"),
1225 "sid" => array("sid"),
1226 "expire" => array("expire"),
1229 $database["sign"] = array(
1231 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1232 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1233 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1234 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1235 "signature" => array("type" => "text", "not null" => "1"),
1236 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1239 "PRIMARY" => array("id"),
1240 "iid" => array("iid"),
1241 "retract_iid" => array("retract_iid"),
1244 $database["spam"] = array(
1246 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1247 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1248 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1249 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1250 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1251 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1254 "PRIMARY" => array("id"),
1255 "uid" => array("uid"),
1256 "spam" => array("spam"),
1257 "ham" => array("ham"),
1258 "term" => array("term"),
1261 $database["term"] = array(
1263 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1264 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1265 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1266 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1267 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1268 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1269 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1270 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1271 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1272 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1273 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1274 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1277 "PRIMARY" => array("tid"),
1278 "oid_otype_type_term" => array("oid","otype","type","term"),
1279 "uid_term_tid" => array("uid","term","tid"),
1280 "type_term" => array("type","term"),
1281 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1282 "otype_type_term_tid" => array("otype","type","term","tid"),
1283 "guid" => array("guid"),
1286 $database["thread"] = array(
1288 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1289 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1290 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1291 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1292 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1293 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1294 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1295 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1296 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1297 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1298 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1299 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1300 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1301 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1302 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1303 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1304 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1305 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1306 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1307 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1308 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1309 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1310 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1313 "PRIMARY" => array("iid"),
1314 "created" => array("created"),
1315 "commented" => array("commented"),
1316 "uid_network_commented" => array("uid","network","commented"),
1317 "uid_network_created" => array("uid","network","created"),
1318 "uid_contactid_commented" => array("uid","contact-id","commented"),
1319 "uid_contactid_created" => array("uid","contact-id","created"),
1320 "wall_private_received" => array("wall","private","received"),
1321 "uid_created" => array("uid","created"),
1322 "uid_commented" => array("uid","commented"),
1325 $database["tokens"] = array(
1327 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1328 "secret" => array("type" => "text", "not null" => "1"),
1329 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1330 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1331 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1332 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1335 "PRIMARY" => array("id"),
1338 $database["unique_contacts"] = array(
1340 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1341 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1342 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1343 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1344 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1345 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1346 "about" => array("type" => "text", "not null" => "1"),
1349 "PRIMARY" => array("id"),
1350 "url" => array("url"),
1353 $database["user"] = array(
1355 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1356 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1357 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1358 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1359 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1360 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1361 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1362 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1363 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1364 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1365 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1366 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1367 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1368 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1369 "pubkey" => array("type" => "text", "not null" => "1"),
1370 "prvkey" => array("type" => "text", "not null" => "1"),
1371 "spubkey" => array("type" => "text", "not null" => "1"),
1372 "sprvkey" => array("type" => "text", "not null" => "1"),
1373 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1374 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1375 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1376 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1377 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1378 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1379 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1380 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1381 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1382 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1383 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1384 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1385 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1386 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1387 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1388 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1389 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1390 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1391 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1392 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1393 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1394 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1395 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1396 "openidserver" => array("type" => "text", "not null" => "1"),
1399 "PRIMARY" => array("uid"),
1400 "nickname" => array("nickname"),
1403 $database["userd"] = array(
1405 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1406 "username" => array("type" => "varchar(255)", "not null" => "1"),
1409 "PRIMARY" => array("id"),
1410 "username" => array("username"),
1413 $database["workerqueue"] = array(
1415 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1416 "parameter" => array("type" => "text", "not null" => "1"),
1417 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1418 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1419 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1420 "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1423 "PRIMARY" => array("id"),
1424 "created" => array("created"),
1433 * run from command line
1435 function dbstructure_run(&$argv, &$argc) {
1443 @include(".htconfig.php");
1444 require_once("include/dba.php");
1445 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1446 unset($db_host, $db_user, $db_pass, $db_data);
1452 update_structure(true, true);
1455 print_structure(db_definition());
1462 echo $argv[0]." <command>\n";
1465 echo "update update database schema\n";
1466 echo "dumpsql dump database schema\n";
1474 if (array_search(__file__,get_included_files())===0){
1475 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);