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) {
268 $primary_keys = array();
269 foreach($fields AS $fieldname => $field) {
270 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
271 if (x($field,'primary') and $field['primary']!=''){
272 $primary_keys[] = $fieldname;
276 if (!is_null($indexes)) {
277 foreach ($indexes AS $indexname => $fieldnames) {
278 $sql_index = db_create_index($indexname, $fieldnames, "");
279 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
283 $sql = implode(",\n\t", $sql_rows);
285 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
295 function db_add_table_field($fieldname, $parameters) {
296 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
300 function db_modify_table_field($fieldname, $parameters) {
301 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
305 function db_drop_index($indexname) {
306 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
310 function db_create_index($indexname, $fieldnames, $method="ADD") {
312 $method = strtoupper(trim($method));
313 if ($method!="" && $method!="ADD") {
314 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
319 if ($indexname == "PRIMARY") {
320 return sprintf("%s PRIMARY KEY(`%s`)", $method, implode("`,`", $fieldnames));
324 foreach ($fieldnames AS $fieldname) {
328 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
329 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
331 $names .= "`".dbesc($fieldname)."`";
335 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
339 function db_definition() {
343 $database["addon"] = array(
345 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
346 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
347 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
348 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
349 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
350 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
351 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
354 "PRIMARY" => array("id"),
357 $database["attach"] = array(
359 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
360 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
361 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
362 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
363 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
364 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
365 "data" => array("type" => "longblob", "not null" => "1"),
366 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
367 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
368 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
369 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
370 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
371 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
374 "PRIMARY" => array("id"),
377 $database["auth_codes"] = array(
379 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
380 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
381 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
382 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
383 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
386 "PRIMARY" => array("id"),
389 $database["cache"] = array(
391 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
392 "v" => array("type" => "text", "not null" => "1"),
393 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
394 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
397 "PRIMARY" => array("k"),
398 "updated" => array("updated"),
401 $database["challenge"] = array(
403 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
404 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
405 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
406 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
407 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
408 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
411 "PRIMARY" => array("id"),
414 $database["clients"] = array(
416 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
417 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
418 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
419 "name" => array("type" => "text"),
420 "icon" => array("type" => "text"),
421 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
424 "PRIMARY" => array("client_id"),
427 $database["config"] = array(
429 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
430 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
431 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
432 "v" => array("type" => "text", "not null" => "1"),
435 "PRIMARY" => array("id"),
436 "cat_k" => array("cat(30)","k(30)"),
439 $database["contact"] = array(
441 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
442 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
443 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
444 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
445 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
446 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
447 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
448 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
449 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
450 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
451 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
452 "about" => array("type" => "text", "not null" => "1"),
453 "keywords" => array("type" => "text", "not null" => "1"),
454 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
455 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
456 "avatar" => 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["event"] = array(
542 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
543 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
544 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
545 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
546 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
547 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
548 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
549 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
550 "summary" => array("type" => "text", "not null" => "1"),
551 "desc" => array("type" => "text", "not null" => "1"),
552 "location" => array("type" => "text", "not null" => "1"),
553 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
554 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
555 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
556 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
557 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
558 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
559 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
560 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
563 "PRIMARY" => array("id"),
564 "uid" => array("uid"),
567 $database["fcontact"] = array(
569 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
570 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
571 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
572 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
573 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
574 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
575 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
576 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
577 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
578 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
579 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
580 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
581 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
582 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
583 "pubkey" => array("type" => "text", "not null" => "1"),
584 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
587 "PRIMARY" => array("id"),
588 "addr" => array("addr"),
591 $database["ffinder"] = array(
593 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
594 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
595 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
596 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
599 "PRIMARY" => array("id"),
602 $database["fserver"] = array(
604 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
605 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
606 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
607 "key" => array("type" => "text", "not null" => "1"),
610 "PRIMARY" => array("id"),
611 "server" => array("server"),
614 $database["fsuggest"] = array(
616 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
617 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
618 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
619 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
620 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
621 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
622 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
623 "note" => array("type" => "text", "not null" => "1"),
624 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
627 "PRIMARY" => array("id"),
630 $database["gcign"] = array(
632 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
633 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
634 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
637 "PRIMARY" => array("id"),
638 "uid" => array("uid"),
639 "gcid" => array("gcid"),
642 $database["gcontact"] = array(
644 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
645 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
646 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
647 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
648 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
649 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
650 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
651 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
652 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
653 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
654 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
655 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
656 "about" => array("type" => "text", "not null" => "1"),
657 "keywords" => array("type" => "text", "not null" => "1"),
658 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
659 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
660 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
661 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
662 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
663 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
664 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
665 "notify" => array("type" => "text", "not null" => "1"),
666 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
667 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
668 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
671 "PRIMARY" => array("id"),
672 "nurl" => array("nurl"),
673 "updated" => array("updated"),
676 $database["glink"] = array(
678 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
679 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
680 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
681 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
682 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
683 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
686 "PRIMARY" => array("id"),
687 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
688 "gcid" => array("gcid"),
689 "zcid" => array("zcid"),
692 $database["group"] = array(
694 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
695 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
696 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
697 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
698 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
701 "PRIMARY" => array("id"),
702 "uid" => array("uid"),
705 $database["group_member"] = 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 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
710 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
713 "PRIMARY" => array("id"),
714 "uid_gid_contactid" => array("uid","gid","contact-id"),
717 $database["gserver"] = array(
719 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
720 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
721 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
722 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
723 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
724 "info" => array("type" => "text", "not null" => "1"),
725 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
726 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
727 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
728 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
729 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
730 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
731 "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
732 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
733 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
736 "PRIMARY" => array("id"),
737 "nurl" => array("nurl"),
740 $database["hook"] = array(
742 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
743 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
749 "PRIMARY" => array("id"),
750 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
753 $database["intro"] = array(
755 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
756 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
757 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
758 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
759 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
760 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
761 "note" => array("type" => "text", "not null" => "1"),
762 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
763 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
764 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
765 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
768 "PRIMARY" => array("id"),
771 $database["item"] = array(
773 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
774 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
775 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
776 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
777 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
778 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
779 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
780 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
781 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
783 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
784 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
785 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
786 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
787 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
788 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
789 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
790 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
791 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
792 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
793 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
794 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
795 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
796 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
797 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
798 "body" => array("type" => "mediumtext", "not null" => "1"),
799 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
800 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
801 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
802 "object" => array("type" => "text", "not null" => "1"),
803 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
804 "target" => array("type" => "text", "not null" => "1"),
805 "postopts" => array("type" => "text", "not null" => "1"),
806 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
807 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
808 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
809 "tag" => array("type" => "mediumtext", "not null" => "1"),
810 "attach" => array("type" => "mediumtext", "not null" => "1"),
811 "inform" => array("type" => "mediumtext", "not null" => "1"),
812 "file" => array("type" => "mediumtext", "not null" => "1"),
813 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
814 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
815 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
816 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
817 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
818 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
819 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
820 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
821 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
822 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
823 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
824 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
825 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
826 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
827 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
828 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
829 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
830 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
831 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
832 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
833 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
834 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
835 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
838 "PRIMARY" => array("id"),
839 "guid" => array("guid"),
840 "uri" => array("uri"),
841 "parent" => array("parent"),
842 "parent-uri" => array("parent-uri"),
843 "extid" => array("extid"),
844 "uid_id" => array("uid","id"),
845 "uid_created" => array("uid","created"),
846 "uid_unseen" => array("uid","unseen"),
847 "uid_network_received" => array("uid","network","received"),
848 "uid_received" => array("uid","received"),
849 "uid_network_commented" => array("uid","network","commented"),
850 "uid_commented" => array("uid","commented"),
851 "uid_title" => array("uid","title"),
852 "uid_thrparent" => array("uid","thr-parent"),
853 "uid_parenturi" => array("uid","parent-uri"),
854 "uid_contactid_created" => array("uid","contact-id","created"),
855 "gcontactid_uid_created" => array("gcontact-id","uid","created"),
856 "wall_body" => array("wall","body(6)"),
857 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
858 "uid_uri" => array("uid","uri"),
859 "uid_wall_created" => array("uid","wall","created"),
860 "resource-id" => array("resource-id"),
861 "uid_type" => array("uid","type"),
862 "uid_starred" => array("uid","starred"),
863 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
864 "uid_wall_parent_created" => array("uid","wall","parent","created"),
865 "uid_type_changed" => array("uid","type","changed"),
866 "contactid_verb" => array("contact-id","verb"),
867 "deleted_changed" => array("deleted","changed"),
868 "uid_wall_changed" => array("uid","wall","changed"),
869 "uid_eventid" => array("uid","event-id"),
870 "uid_authorlink" => array("uid","author-link"),
871 "uid_ownerlink" => array("uid","owner-link"),
874 $database["item_id"] = array(
876 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
877 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
878 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
879 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
880 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
883 "PRIMARY" => array("id"),
884 "uid" => array("uid"),
885 "sid" => array("sid"),
886 "service" => array("service"),
887 "iid" => array("iid"),
890 $database["locks"] = array(
892 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
893 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
894 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
895 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
898 "PRIMARY" => array("id"),
901 $database["mail"] = array(
903 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
904 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
905 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
906 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
907 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
908 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
909 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
910 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
911 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
912 "body" => array("type" => "mediumtext", "not null" => "1"),
913 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
914 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
915 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
916 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
917 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
918 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
919 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
922 "PRIMARY" => array("id"),
923 "uid" => array("uid"),
924 "guid" => array("guid"),
925 "convid" => array("convid"),
926 "reply" => array("reply"),
927 "uri" => array("uri"),
928 "parent-uri" => array("parent-uri"),
931 $database["mailacct"] = array(
933 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
934 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
935 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
936 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
937 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
938 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
939 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
940 "pass" => array("type" => "text", "not null" => "1"),
941 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
942 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
943 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
944 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
945 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
948 "PRIMARY" => array("id"),
951 $database["manage"] = array(
953 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
954 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
955 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
958 "PRIMARY" => array("id"),
959 "uid_mid" => array("uid","mid"),
962 $database["notify"] = array(
964 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
965 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
966 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
967 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
968 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
969 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
970 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
971 "msg" => array("type" => "mediumtext", "not null" => "1"),
972 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
973 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
974 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
975 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
976 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
977 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
978 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
981 "PRIMARY" => array("id"),
982 "uid" => array("uid"),
985 $database["notify-threads"] = array(
987 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
988 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
989 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
990 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
991 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
994 "PRIMARY" => array("id"),
995 "master-parent-item" => array("master-parent-item"),
996 "receiver-uid" => array("receiver-uid"),
999 $database["oembed"] = array(
1001 "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
1002 "content" => array("type" => "text", "not null" => "1"),
1003 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1006 "PRIMARY" => array("url"),
1007 "created" => array("created"),
1010 $database["parsed_url"] = array(
1012 "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
1013 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1014 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1015 "content" => array("type" => "text", "not null" => "1"),
1016 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1019 "PRIMARY" => array("url", "guessing", "oembed"),
1020 "created" => array("created"),
1023 $database["pconfig"] = array(
1025 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1026 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1027 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1028 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1029 "v" => array("type" => "mediumtext", "not null" => "1"),
1032 "PRIMARY" => array("id"),
1033 "uid_cat_k" => array("uid","cat(30)","k(30)"),
1036 $database["photo"] = array(
1038 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1039 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1040 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1041 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1042 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1044 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1045 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "desc" => array("type" => "text", "not null" => "1"),
1047 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1050 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1051 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1052 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1053 "data" => array("type" => "mediumblob", "not null" => "1"),
1054 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1055 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1056 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1057 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1058 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1059 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1062 "PRIMARY" => array("id"),
1063 "uid" => array("uid"),
1064 "resource-id" => array("resource-id"),
1065 "guid" => array("guid"),
1068 $database["poll"] = array(
1070 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1071 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1072 "q0" => array("type" => "mediumtext", "not null" => "1"),
1073 "q1" => array("type" => "mediumtext", "not null" => "1"),
1074 "q2" => array("type" => "mediumtext", "not null" => "1"),
1075 "q3" => array("type" => "mediumtext", "not null" => "1"),
1076 "q4" => array("type" => "mediumtext", "not null" => "1"),
1077 "q5" => array("type" => "mediumtext", "not null" => "1"),
1078 "q6" => array("type" => "mediumtext", "not null" => "1"),
1079 "q7" => array("type" => "mediumtext", "not null" => "1"),
1080 "q8" => array("type" => "mediumtext", "not null" => "1"),
1081 "q9" => array("type" => "mediumtext", "not null" => "1"),
1084 "PRIMARY" => array("id"),
1085 "uid" => array("uid"),
1088 $database["poll_result"] = array(
1090 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1091 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1092 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1095 "PRIMARY" => array("id"),
1096 "poll_id" => array("poll_id"),
1097 "choice" => array("choice"),
1100 $database["profile"] = array(
1102 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1103 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1104 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1106 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1107 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1108 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1109 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1110 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1111 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1112 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1113 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1114 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1115 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1117 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1118 "with" => array("type" => "text", "not null" => "1"),
1119 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1120 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1121 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1122 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123 "pub_keywords" => array("type" => "text", "not null" => "1"),
1124 "prv_keywords" => array("type" => "text", "not null" => "1"),
1125 "likes" => array("type" => "text", "not null" => "1"),
1126 "dislikes" => array("type" => "text", "not null" => "1"),
1127 "about" => array("type" => "text", "not null" => "1"),
1128 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1129 "music" => array("type" => "text", "not null" => "1"),
1130 "book" => array("type" => "text", "not null" => "1"),
1131 "tv" => array("type" => "text", "not null" => "1"),
1132 "film" => array("type" => "text", "not null" => "1"),
1133 "interest" => array("type" => "text", "not null" => "1"),
1134 "romance" => array("type" => "text", "not null" => "1"),
1135 "work" => array("type" => "text", "not null" => "1"),
1136 "education" => array("type" => "text", "not null" => "1"),
1137 "contact" => array("type" => "text", "not null" => "1"),
1138 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1139 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1140 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1141 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1142 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1145 "PRIMARY" => array("id"),
1146 "hometown" => array("hometown"),
1149 $database["profile_check"] = array(
1151 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1152 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1153 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1154 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1155 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1156 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1159 "PRIMARY" => array("id"),
1162 $database["push_subscriber"] = array(
1164 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1165 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1166 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1167 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1168 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1169 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1170 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1171 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1174 "PRIMARY" => array("id"),
1177 $database["queue"] = array(
1179 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1180 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1181 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1182 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1183 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1184 "content" => array("type" => "mediumtext", "not null" => "1"),
1185 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1188 "PRIMARY" => array("id"),
1189 "cid" => array("cid"),
1190 "created" => array("created"),
1191 "last" => array("last"),
1192 "network" => array("network"),
1193 "batch" => array("batch"),
1196 $database["register"] = array(
1198 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1199 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1200 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1201 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1202 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1203 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1206 "PRIMARY" => array("id"),
1209 $database["search"] = array(
1211 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1212 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1213 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1216 "PRIMARY" => array("id"),
1217 "uid" => array("uid"),
1218 "term" => array("term"),
1221 $database["session"] = array(
1223 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1224 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1225 "data" => array("type" => "text", "not null" => "1"),
1226 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1229 "PRIMARY" => array("id"),
1230 "sid" => array("sid"),
1231 "expire" => array("expire"),
1234 $database["sign"] = array(
1236 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1237 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1238 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1239 "signature" => array("type" => "text", "not null" => "1"),
1240 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1243 "PRIMARY" => array("id"),
1244 "iid" => array("iid"),
1247 $database["spam"] = array(
1249 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1250 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1251 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1252 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1253 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1254 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1257 "PRIMARY" => array("id"),
1258 "uid" => array("uid"),
1259 "spam" => array("spam"),
1260 "ham" => array("ham"),
1261 "term" => array("term"),
1264 $database["term"] = array(
1266 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1267 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1268 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1269 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1270 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1271 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1272 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1273 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1274 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1275 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1276 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1277 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1280 "PRIMARY" => array("tid"),
1281 "oid_otype_type_term" => array("oid","otype","type","term"),
1282 "uid_term_tid" => array("uid","term","tid"),
1283 "type_term" => array("type","term"),
1284 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1285 "otype_type_term_tid" => array("otype","type","term","tid"),
1286 "guid" => array("guid"),
1289 $database["thread"] = array(
1291 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1292 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1293 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1294 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1295 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1296 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1297 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1298 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1299 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1300 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1301 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1302 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1303 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1304 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1305 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1306 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1307 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1308 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1309 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1310 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1311 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1312 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1313 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1314 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1317 "PRIMARY" => array("iid"),
1318 "created" => array("created"),
1319 "commented" => array("commented"),
1320 "uid_network_commented" => array("uid","network","commented"),
1321 "uid_network_created" => array("uid","network","created"),
1322 "uid_contactid_commented" => array("uid","contact-id","commented"),
1323 "uid_contactid_created" => array("uid","contact-id","created"),
1324 "uid_gcontactid_commented" => array("uid","gcontact-id","commented"),
1325 "uid_gcontactid_created" => array("uid","gcontact-id","created"),
1326 "wall_private_received" => array("wall","private","received"),
1327 "uid_created" => array("uid","created"),
1328 "uid_commented" => array("uid","commented"),
1331 $database["tokens"] = array(
1333 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1334 "secret" => array("type" => "text", "not null" => "1"),
1335 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1336 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1337 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1338 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1341 "PRIMARY" => array("id"),
1344 $database["user"] = array(
1346 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1347 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1348 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1349 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1350 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1351 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1352 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1353 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1354 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1355 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1356 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1357 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1358 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1359 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1360 "pubkey" => array("type" => "text", "not null" => "1"),
1361 "prvkey" => array("type" => "text", "not null" => "1"),
1362 "spubkey" => array("type" => "text", "not null" => "1"),
1363 "sprvkey" => array("type" => "text", "not null" => "1"),
1364 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1365 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1366 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1367 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1368 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1369 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1370 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1371 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1372 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1373 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1374 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1375 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1376 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1377 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1378 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1379 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1380 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1381 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1382 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1383 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1384 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1385 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1386 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1387 "openidserver" => array("type" => "text", "not null" => "1"),
1390 "PRIMARY" => array("uid"),
1391 "nickname" => array("nickname"),
1394 $database["userd"] = array(
1396 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1397 "username" => array("type" => "varchar(255)", "not null" => "1"),
1400 "PRIMARY" => array("id"),
1401 "username" => array("username"),
1404 $database["workerqueue"] = array(
1406 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1407 "parameter" => array("type" => "text", "not null" => "1"),
1408 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1409 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1410 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1411 "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1414 "PRIMARY" => array("id"),
1415 "created" => array("created"),
1424 * run from command line
1426 function dbstructure_run(&$argv, &$argc) {
1434 @include(".htconfig.php");
1435 require_once("include/dba.php");
1436 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1437 unset($db_host, $db_user, $db_pass, $db_data);
1443 update_structure(true, true);
1446 print_structure(db_definition());
1453 echo $argv[0]." <command>\n";
1456 echo "update update database schema\n";
1457 echo "dumpsql dump database schema\n";
1465 if (array_search(__file__,get_included_files())===0){
1466 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);