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();
147 foreach ($definition AS $name => $structure) {
149 if (!isset($database[$name])) {
150 $r = db_create_table($name, $structure["fields"], $verbose, $action);
152 $errors .= t('Errors encountered creating database tables.').$name.EOL;
155 // Drop the index if it isn't present in the definition and index name doesn't start with "local_"
156 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
157 if (!isset($structure["indexes"][$indexname]) && substr($indexname, 0, 6) != 'local_') {
158 $sql2=db_drop_index($indexname);
160 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
165 // Compare the field structure field by field
166 foreach ($structure["fields"] AS $fieldname => $parameters) {
167 if (!isset($database[$name]["fields"][$fieldname])) {
168 $sql2=db_add_table_field($fieldname, $parameters);
170 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
174 // Compare the field definition
175 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
176 $new_field_definition = implode(",",$parameters);
177 if ($current_field_definition != $new_field_definition) {
178 $sql2=db_modify_table_field($fieldname, $parameters);
180 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
190 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
191 if (!isset($database[$name]["indexes"][$indexname])) {
192 $sql2=db_create_index($indexname, $fieldnames);
195 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
211 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
219 function db_field_command($parameters, $create = true) {
220 $fieldstruct = $parameters["type"];
222 if ($parameters["not null"])
223 $fieldstruct .= " NOT NULL";
225 if (isset($parameters["default"])){
226 if (strpos(strtolower($parameters["type"]),"int")!==false) {
227 $fieldstruct .= " DEFAULT ".$parameters["default"];
229 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
232 if ($parameters["extra"] != "")
233 $fieldstruct .= " ".$parameters["extra"];
235 /*if (($parameters["primary"] != "") AND $create)
236 $fieldstruct .= " PRIMARY KEY";*/
238 return($fieldstruct);
241 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
249 $primary_keys = array();
250 foreach($fields AS $fieldname => $field) {
251 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
252 if (x($field,'primary') and $field['primary']!=''){
253 $primary_keys[] = $fieldname;
257 if (!is_null($indexes)) {
259 foreach ($indexes AS $indexname => $fieldnames) {
260 $sql_index = db_create_index($indexname, $fieldnames, "");
261 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
265 if (count($primary_keys)>0) {
266 $sql_rows[] = sprintf("PRIMARY KEY(`%s`)", implode("`,`", $primary_keys));
269 $sql = implode(",\n\t", $sql_rows);
271 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
281 function db_add_table_field($fieldname, $parameters) {
282 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
286 function db_modify_table_field($fieldname, $parameters) {
287 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
291 function db_drop_index($indexname) {
292 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
296 function db_create_index($indexname, $fieldnames, $method="ADD") {
298 if ($indexname == "PRIMARY")
302 foreach ($fieldnames AS $fieldname) {
306 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
307 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
309 $names .= "`".dbesc($fieldname)."`";
312 $method = strtoupper(trim($method));
313 if ($method!="" && $method!="ADD") {
314 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
318 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
322 function db_definition() {
326 $database["addon"] = array(
328 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
329 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
330 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
331 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
332 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
333 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
334 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
337 "PRIMARY" => array("id"),
340 $database["attach"] = array(
342 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
343 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
344 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
345 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
346 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
347 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
348 "data" => array("type" => "longblob", "not null" => "1"),
349 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
350 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
351 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
352 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
353 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
354 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
357 "PRIMARY" => array("id"),
360 $database["auth_codes"] = array(
362 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
363 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
364 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
365 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
366 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
369 "PRIMARY" => array("id"),
372 $database["cache"] = array(
374 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
375 "v" => array("type" => "text", "not null" => "1"),
376 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
377 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
380 "PRIMARY" => array("k"),
381 "updated" => array("updated"),
384 $database["challenge"] = array(
386 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
387 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
388 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
389 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
390 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
391 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
394 "PRIMARY" => array("id"),
397 $database["clients"] = array(
399 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
400 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
401 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
402 "name" => array("type" => "text"),
403 "icon" => array("type" => "text"),
404 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
407 "PRIMARY" => array("client_id"),
410 $database["config"] = array(
412 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
413 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
414 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
415 "v" => array("type" => "text", "not null" => "1"),
418 "PRIMARY" => array("id"),
419 "cat_k" => array("cat(30)","k(30)"),
422 $database["contact"] = array(
424 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
425 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
426 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
427 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
428 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
429 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
430 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
431 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
432 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
433 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
434 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
435 "about" => array("type" => "text", "not null" => "1"),
436 "keywords" => array("type" => "text", "not null" => "1"),
437 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
438 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
439 "photo" => array("type" => "text", "not null" => "1"),
440 "thumb" => array("type" => "text", "not null" => "1"),
441 "micro" => array("type" => "text", "not null" => "1"),
442 "site-pubkey" => array("type" => "text", "not null" => "1"),
443 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
444 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
445 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
446 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
447 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
448 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
449 "pubkey" => array("type" => "text", "not null" => "1"),
450 "prvkey" => array("type" => "text", "not null" => "1"),
451 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
452 "request" => array("type" => "text", "not null" => "1"),
453 "notify" => array("type" => "text", "not null" => "1"),
454 "poll" => array("type" => "text", "not null" => "1"),
455 "confirm" => array("type" => "text", "not null" => "1"),
456 "poco" => array("type" => "text", "not null" => "1"),
457 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
458 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
459 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
460 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
461 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
462 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
463 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
464 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
465 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
466 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
467 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
468 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
469 "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
470 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
471 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
472 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
473 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
474 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
475 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
476 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
477 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
478 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
479 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
480 "reason" => array("type" => "text", "not null" => "1"),
481 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
482 "info" => array("type" => "mediumtext", "not null" => "1"),
483 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
484 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
485 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
486 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
487 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
488 "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
491 "PRIMARY" => array("id"),
492 "uid" => array("uid"),
495 $database["conv"] = array(
497 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
498 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
499 "recips" => array("type" => "mediumtext", "not null" => "1"),
500 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
501 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
502 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
503 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
504 "subject" => array("type" => "mediumtext", "not null" => "1"),
507 "PRIMARY" => array("id"),
508 "uid" => array("uid"),
511 $database["deliverq"] = array(
513 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
514 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
515 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
516 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
519 "PRIMARY" => array("id"),
522 $database["dsprphotoq"] = array(
524 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
525 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
526 "msg" => array("type" => "mediumtext", "not null" => "1"),
527 "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
530 "PRIMARY" => array("id"),
533 $database["event"] = array(
535 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
536 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
537 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
538 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
539 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
540 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
541 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
542 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
543 "summary" => array("type" => "text", "not null" => "1"),
544 "desc" => array("type" => "text", "not null" => "1"),
545 "location" => array("type" => "text", "not null" => "1"),
546 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
547 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
548 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
549 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
550 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
551 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
552 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
553 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
556 "PRIMARY" => array("id"),
557 "uid" => array("uid"),
560 $database["fcontact"] = array(
562 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
563 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
564 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
565 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
566 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
567 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
568 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
569 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
570 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
571 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
572 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
573 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
574 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
575 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
576 "pubkey" => array("type" => "text", "not null" => "1"),
577 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
580 "PRIMARY" => array("id"),
581 "addr" => array("addr"),
584 $database["ffinder"] = array(
586 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
587 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
588 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
589 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
592 "PRIMARY" => array("id"),
595 $database["fserver"] = array(
597 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
598 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
599 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
600 "key" => array("type" => "text", "not null" => "1"),
603 "PRIMARY" => array("id"),
604 "server" => array("server"),
607 $database["fsuggest"] = array(
609 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
610 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
611 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
612 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
613 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
614 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
615 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
616 "note" => array("type" => "text", "not null" => "1"),
617 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
620 "PRIMARY" => array("id"),
623 $database["gcign"] = array(
625 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
626 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
627 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
630 "PRIMARY" => array("id"),
631 "uid" => array("uid"),
632 "gcid" => array("gcid"),
635 $database["gcontact"] = array(
637 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
638 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
639 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
640 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
641 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
642 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
643 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
644 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
645 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
646 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
647 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
648 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
649 "about" => array("type" => "text", "not null" => "1"),
650 "keywords" => array("type" => "text", "not null" => "1"),
651 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
652 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
653 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
654 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
655 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
656 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
659 "PRIMARY" => array("id"),
660 "nurl" => array("nurl"),
661 "updated" => array("updated"),
664 $database["glink"] = array(
666 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
667 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
668 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
669 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
670 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
671 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
674 "PRIMARY" => array("id"),
675 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
676 "gcid" => array("gcid"),
677 "zcid" => array("zcid"),
680 $database["group"] = array(
682 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
683 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
684 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
685 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
686 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
689 "PRIMARY" => array("id"),
690 "uid" => array("uid"),
693 $database["group_member"] = array(
695 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
696 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
697 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
698 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
701 "PRIMARY" => array("id"),
702 "uid_gid_contactid" => array("uid","gid","contact-id"),
705 $database["gserver"] = array(
707 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
708 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
709 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
710 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
711 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
712 "info" => array("type" => "text", "not null" => "1"),
713 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
714 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
715 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
716 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
717 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
718 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
719 "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
720 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
721 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
724 "PRIMARY" => array("id"),
725 "nurl" => array("nurl"),
728 $database["guid"] = array(
730 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
731 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
733 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
737 "PRIMARY" => array("id"),
738 "guid" => array("guid"),
739 "plink" => array("plink"),
740 "uri" => array("uri"),
743 $database["hook"] = array(
745 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
746 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
752 "PRIMARY" => array("id"),
753 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
756 $database["intro"] = array(
758 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
759 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
760 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
761 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
762 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
763 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
764 "note" => array("type" => "text", "not null" => "1"),
765 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
766 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
767 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
768 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "PRIMARY" => array("id"),
774 $database["item"] = array(
776 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
777 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
778 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
779 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
780 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
781 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
782 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
783 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
784 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
785 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
786 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
787 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
788 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
789 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
790 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
791 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
792 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
793 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
794 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
795 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
796 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
797 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
798 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
799 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
800 "body" => array("type" => "mediumtext", "not null" => "1"),
801 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
802 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
803 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
804 "object" => array("type" => "text", "not null" => "1"),
805 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
806 "target" => array("type" => "text", "not null" => "1"),
807 "postopts" => array("type" => "text", "not null" => "1"),
808 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
809 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
810 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
811 "tag" => array("type" => "mediumtext", "not null" => "1"),
812 "attach" => array("type" => "mediumtext", "not null" => "1"),
813 "inform" => array("type" => "mediumtext", "not null" => "1"),
814 "file" => array("type" => "mediumtext", "not null" => "1"),
815 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
816 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
817 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
818 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
819 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
820 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
821 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
822 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
823 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
824 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
825 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
826 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
827 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
828 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
829 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
830 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
831 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
832 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
833 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
834 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
835 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
836 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
837 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
840 "PRIMARY" => array("id"),
841 "guid" => array("guid"),
842 "uri" => array("uri"),
843 "parent" => array("parent"),
844 "parent-uri" => array("parent-uri"),
845 "extid" => array("extid"),
846 "uid_id" => array("uid","id"),
847 "uid_created" => array("uid","created"),
848 "uid_unseen" => array("uid","unseen"),
849 "uid_network_received" => array("uid","network","received"),
850 "uid_received" => array("uid","received"),
851 "uid_network_commented" => array("uid","network","commented"),
852 "uid_commented" => array("uid","commented"),
853 "uid_title" => array("uid","title"),
854 "uid_thrparent" => array("uid","thr-parent"),
855 "uid_parenturi" => array("uid","parent-uri"),
856 "uid_contactid_created" => array("uid","contact-id","created"),
857 "wall_body" => array("wall","body(6)"),
858 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
859 "uid_uri" => array("uid","uri"),
860 "uid_wall_created" => array("uid","wall","created"),
861 "resource-id" => array("resource-id"),
862 "uid_type" => array("uid","type"),
863 "uid_starred" => array("uid","starred"),
864 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
865 "uid_wall_parent_created" => array("uid","wall","parent","created"),
866 "uid_type_changed" => array("uid","type","changed"),
867 "contactid_verb" => array("contact-id","verb"),
868 "deleted_changed" => array("deleted","changed"),
869 "uid_wall_changed" => array("uid","wall","changed"),
870 "uid_eventid" => array("uid","event-id"),
871 "uid_authorlink" => array("uid","author-link"),
872 "uid_ownerlink" => array("uid","owner-link"),
875 $database["item_id"] = array(
877 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
878 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
879 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
880 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
881 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884 "PRIMARY" => array("id"),
885 "uid" => array("uid"),
886 "sid" => array("sid"),
887 "service" => array("service"),
888 "iid" => array("iid"),
891 $database["locks"] = array(
893 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
894 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
895 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
896 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
899 "PRIMARY" => array("id"),
902 $database["mail"] = array(
904 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
905 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
906 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
907 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
908 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
909 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
910 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
911 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
912 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
913 "body" => array("type" => "mediumtext", "not null" => "1"),
914 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
915 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
916 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
917 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
918 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
919 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
920 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
923 "PRIMARY" => array("id"),
924 "uid" => array("uid"),
925 "guid" => array("guid"),
926 "convid" => array("convid"),
927 "reply" => array("reply"),
928 "uri" => array("uri"),
929 "parent-uri" => array("parent-uri"),
932 $database["mailacct"] = array(
934 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
935 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
936 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
937 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
938 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
939 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
940 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
941 "pass" => array("type" => "text", "not null" => "1"),
942 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
943 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
944 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
945 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
946 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
949 "PRIMARY" => array("id"),
952 $database["manage"] = array(
954 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
955 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
956 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
959 "PRIMARY" => array("id"),
960 "uid_mid" => array("uid","mid"),
963 $database["notify"] = array(
965 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
966 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
967 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
968 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
969 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
970 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
971 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
972 "msg" => array("type" => "mediumtext", "not null" => "1"),
973 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
974 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
975 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
976 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
977 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
978 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
979 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
982 "PRIMARY" => array("id"),
983 "uid" => array("uid"),
986 $database["notify-threads"] = array(
988 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
989 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
990 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
991 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
992 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
995 "PRIMARY" => array("id"),
996 "master-parent-item" => array("master-parent-item"),
997 "receiver-uid" => array("receiver-uid"),
1000 $database["pconfig"] = array(
1002 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1003 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1004 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1005 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1006 "v" => array("type" => "mediumtext", "not null" => "1"),
1009 "PRIMARY" => array("id"),
1010 "uid_cat_k" => array("uid","cat(30)","k(30)"),
1013 $database["photo"] = array(
1015 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1016 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1017 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1018 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1019 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1020 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1021 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1022 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "desc" => array("type" => "text", "not null" => "1"),
1024 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1025 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1026 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1027 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1028 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1029 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1030 "data" => array("type" => "mediumblob", "not null" => "1"),
1031 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1032 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1033 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1034 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1035 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1036 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1039 "PRIMARY" => array("id"),
1040 "uid" => array("uid"),
1041 "resource-id" => array("resource-id"),
1042 "guid" => array("guid"),
1045 $database["poll"] = array(
1047 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1048 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1049 "q0" => array("type" => "mediumtext", "not null" => "1"),
1050 "q1" => array("type" => "mediumtext", "not null" => "1"),
1051 "q2" => array("type" => "mediumtext", "not null" => "1"),
1052 "q3" => array("type" => "mediumtext", "not null" => "1"),
1053 "q4" => array("type" => "mediumtext", "not null" => "1"),
1054 "q5" => array("type" => "mediumtext", "not null" => "1"),
1055 "q6" => array("type" => "mediumtext", "not null" => "1"),
1056 "q7" => array("type" => "mediumtext", "not null" => "1"),
1057 "q8" => array("type" => "mediumtext", "not null" => "1"),
1058 "q9" => array("type" => "mediumtext", "not null" => "1"),
1061 "PRIMARY" => array("id"),
1062 "uid" => array("uid"),
1065 $database["poll_result"] = array(
1067 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1068 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1069 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1072 "PRIMARY" => array("id"),
1073 "poll_id" => array("poll_id"),
1074 "choice" => array("choice"),
1077 $database["profile"] = array(
1079 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1080 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1081 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1082 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1083 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1084 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1085 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1086 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1087 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1088 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1089 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1090 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1091 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1092 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1094 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1095 "with" => array("type" => "text", "not null" => "1"),
1096 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1097 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1098 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1099 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1100 "pub_keywords" => array("type" => "text", "not null" => "1"),
1101 "prv_keywords" => array("type" => "text", "not null" => "1"),
1102 "likes" => array("type" => "text", "not null" => "1"),
1103 "dislikes" => array("type" => "text", "not null" => "1"),
1104 "about" => array("type" => "text", "not null" => "1"),
1105 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "music" => array("type" => "text", "not null" => "1"),
1107 "book" => array("type" => "text", "not null" => "1"),
1108 "tv" => array("type" => "text", "not null" => "1"),
1109 "film" => array("type" => "text", "not null" => "1"),
1110 "interest" => array("type" => "text", "not null" => "1"),
1111 "romance" => array("type" => "text", "not null" => "1"),
1112 "work" => array("type" => "text", "not null" => "1"),
1113 "education" => array("type" => "text", "not null" => "1"),
1114 "contact" => array("type" => "text", "not null" => "1"),
1115 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1116 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1117 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1118 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1119 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1122 "PRIMARY" => array("id"),
1123 "hometown" => array("hometown"),
1126 $database["profile_check"] = array(
1128 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1129 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1130 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1131 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1132 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1133 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1136 "PRIMARY" => array("id"),
1139 $database["push_subscriber"] = array(
1141 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1142 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1143 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1144 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1145 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1146 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1147 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1148 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1151 "PRIMARY" => array("id"),
1154 $database["queue"] = array(
1156 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1157 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1158 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1159 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1160 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1161 "content" => array("type" => "mediumtext", "not null" => "1"),
1162 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1165 "PRIMARY" => array("id"),
1166 "cid" => array("cid"),
1167 "created" => array("created"),
1168 "last" => array("last"),
1169 "network" => array("network"),
1170 "batch" => array("batch"),
1173 $database["register"] = array(
1175 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1176 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1177 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1178 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1179 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1180 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1183 "PRIMARY" => array("id"),
1186 $database["search"] = array(
1188 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1189 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1190 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1193 "PRIMARY" => array("id"),
1194 "uid" => array("uid"),
1195 "term" => array("term"),
1198 $database["session"] = array(
1200 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1201 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1202 "data" => array("type" => "text", "not null" => "1"),
1203 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1206 "PRIMARY" => array("id"),
1207 "sid" => array("sid"),
1208 "expire" => array("expire"),
1211 $database["sign"] = array(
1213 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1214 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1215 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1216 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1217 "signature" => array("type" => "text", "not null" => "1"),
1218 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1221 "PRIMARY" => array("id"),
1222 "iid" => array("iid"),
1223 "retract_iid" => array("retract_iid"),
1226 $database["spam"] = array(
1228 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1229 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1230 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1231 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1232 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1233 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1236 "PRIMARY" => array("id"),
1237 "uid" => array("uid"),
1238 "spam" => array("spam"),
1239 "ham" => array("ham"),
1240 "term" => array("term"),
1243 $database["term"] = array(
1245 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1246 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1247 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1248 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1249 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1250 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1251 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1252 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1253 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1254 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1255 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1256 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1259 "PRIMARY" => array("tid"),
1260 "oid_otype_type_term" => array("oid","otype","type","term"),
1261 "uid_term_tid" => array("uid","term","tid"),
1262 "type_term" => array("type","term"),
1263 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1264 "otype_type_term_tid" => array("otype","type","term","tid"),
1265 "guid" => array("guid"),
1268 $database["thread"] = array(
1270 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1271 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1272 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1273 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1274 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1275 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1276 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1277 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1278 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1279 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1280 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1281 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1282 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1283 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1284 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1285 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1286 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1287 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1288 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1289 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1290 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1291 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1292 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1295 "PRIMARY" => array("iid"),
1296 "created" => array("created"),
1297 "commented" => array("commented"),
1298 "uid_network_commented" => array("uid","network","commented"),
1299 "uid_network_created" => array("uid","network","created"),
1300 "uid_contactid_commented" => array("uid","contact-id","commented"),
1301 "uid_contactid_created" => array("uid","contact-id","created"),
1302 "wall_private_received" => array("wall","private","received"),
1303 "uid_created" => array("uid","created"),
1304 "uid_commented" => array("uid","commented"),
1307 $database["tokens"] = array(
1309 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1310 "secret" => array("type" => "text", "not null" => "1"),
1311 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1312 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1313 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1314 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1317 "PRIMARY" => array("id"),
1320 $database["unique_contacts"] = array(
1322 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1323 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1324 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1325 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1326 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1327 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1328 "about" => array("type" => "text", "not null" => "1"),
1331 "PRIMARY" => array("id"),
1332 "url" => array("url"),
1335 $database["user"] = array(
1337 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1338 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1339 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1340 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1341 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1342 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1343 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1344 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1345 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1346 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1347 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1348 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1349 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1350 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1351 "pubkey" => array("type" => "text", "not null" => "1"),
1352 "prvkey" => array("type" => "text", "not null" => "1"),
1353 "spubkey" => array("type" => "text", "not null" => "1"),
1354 "sprvkey" => array("type" => "text", "not null" => "1"),
1355 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1356 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1357 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1358 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1359 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1360 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1361 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1362 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1363 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1364 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1365 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1366 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1367 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1368 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1369 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1370 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1371 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1372 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1373 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1374 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1375 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1376 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1377 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1378 "openidserver" => array("type" => "text", "not null" => "1"),
1381 "PRIMARY" => array("uid"),
1382 "nickname" => array("nickname"),
1385 $database["userd"] = array(
1387 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1388 "username" => array("type" => "varchar(255)", "not null" => "1"),
1391 "PRIMARY" => array("id"),
1392 "username" => array("username"),
1395 $database["workerqueue"] = array(
1397 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1398 "parameter" => array("type" => "text", "not null" => "1"),
1399 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1400 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1401 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1402 "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1405 "PRIMARY" => array("id"),
1406 "created" => array("created"),
1415 * run from command line
1417 function dbstructure_run(&$argv, &$argc) {
1425 @include(".htconfig.php");
1426 require_once("include/dba.php");
1427 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1428 unset($db_host, $db_user, $db_pass, $db_data);
1434 update_structure(true, true);
1437 print_structure(db_definition());
1444 echo $argv[0]." <command>\n";
1447 echo "update update database schema\n";
1448 echo "dumpsql dump database schema\n";
1456 if (array_search(__file__,get_included_files())===0){
1457 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);