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;
154 // Drop the index if it isn't present in the definition and index name doesn't start with "local_"
155 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
156 if (!isset($structure["indexes"][$indexname]) && substr($indexname, 0, 6) != 'local_') {
157 $sql2=db_drop_index($indexname);
159 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
164 // Compare the field structure field by field
165 foreach ($structure["fields"] AS $fieldname => $parameters) {
166 if (!isset($database[$name]["fields"][$fieldname])) {
167 $sql2=db_add_table_field($fieldname, $parameters);
169 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
173 // Compare the field definition
174 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
175 $new_field_definition = implode(",",$parameters);
176 if ($current_field_definition != $new_field_definition) {
177 $sql2=db_modify_table_field($fieldname, $parameters);
179 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
189 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
190 if (!isset($database[$name]["indexes"][$indexname])) {
191 $sql2=db_create_index($indexname, $fieldnames);
194 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
210 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
218 function db_field_command($parameters, $create = true) {
219 $fieldstruct = $parameters["type"];
221 if ($parameters["not null"])
222 $fieldstruct .= " NOT NULL";
224 if (isset($parameters["default"])){
225 if (strpos(strtolower($parameters["type"]),"int")!==false) {
226 $fieldstruct .= " DEFAULT ".$parameters["default"];
228 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
231 if ($parameters["extra"] != "")
232 $fieldstruct .= " ".$parameters["extra"];
234 if (($parameters["primary"] != "") AND $create)
235 $fieldstruct .= " PRIMARY KEY";
237 return($fieldstruct);
240 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
247 foreach($fields AS $fieldname => $field) {
248 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
251 if (!is_null($indexes)) {
253 foreach ($indexes AS $indexname => $fieldnames) {
254 $sql_index = db_create_index($indexname, $fieldnames, "");
255 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
259 $sql = implode(",\n\t", $sql_rows);
261 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
272 function db_add_table_field($fieldname, $parameters) {
273 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
277 function db_modify_table_field($fieldname, $parameters) {
278 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
282 function db_drop_index($indexname) {
283 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
287 function db_create_index($indexname, $fieldnames, $method="ADD") {
289 if ($indexname == "PRIMARY")
293 foreach ($fieldnames AS $fieldname) {
297 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
298 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
300 $names .= "`".dbesc($fieldname)."`";
303 $method = strtoupper(trim($method));
304 if ($method!="" && $method!="ADD") {
305 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
309 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
313 function db_definition() {
317 $database["addon"] = array(
319 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
320 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
321 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
322 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
323 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
324 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
325 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
328 "PRIMARY" => array("id"),
331 $database["attach"] = array(
333 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
334 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
335 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
336 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
337 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
338 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
339 "data" => array("type" => "longblob", "not null" => "1"),
340 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
341 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
342 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
343 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
344 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
345 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
348 "PRIMARY" => array("id"),
351 $database["auth_codes"] = array(
353 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
354 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
355 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
356 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
357 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
360 "PRIMARY" => array("id"),
363 $database["cache"] = array(
365 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
366 "v" => array("type" => "text", "not null" => "1"),
367 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
370 "PRIMARY" => array("k"),
371 "updated" => array("updated"),
374 $database["challenge"] = array(
376 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
377 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
378 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
379 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
380 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
381 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
384 "PRIMARY" => array("id"),
387 $database["clients"] = array(
389 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
390 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
391 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
392 "name" => array("type" => "text"),
393 "icon" => array("type" => "text"),
394 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
397 "PRIMARY" => array("client_id"),
400 $database["config"] = array(
402 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
403 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
404 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
405 "v" => array("type" => "text", "not null" => "1"),
408 "PRIMARY" => array("id"),
409 "cat_k" => array("cat(30)","k(30)"),
412 $database["contact"] = array(
414 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
415 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
416 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
417 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
418 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
419 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
420 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
421 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
422 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
423 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
424 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
425 "about" => array("type" => "text", "not null" => "1"),
426 "keywords" => array("type" => "text", "not null" => "1"),
427 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
428 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
429 "photo" => array("type" => "text", "not null" => "1"),
430 "thumb" => array("type" => "text", "not null" => "1"),
431 "micro" => array("type" => "text", "not null" => "1"),
432 "site-pubkey" => array("type" => "text", "not null" => "1"),
433 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
434 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
435 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
436 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
437 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
438 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
439 "pubkey" => array("type" => "text", "not null" => "1"),
440 "prvkey" => array("type" => "text", "not null" => "1"),
441 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
442 "request" => array("type" => "text", "not null" => "1"),
443 "notify" => array("type" => "text", "not null" => "1"),
444 "poll" => array("type" => "text", "not null" => "1"),
445 "confirm" => array("type" => "text", "not null" => "1"),
446 "poco" => array("type" => "text", "not null" => "1"),
447 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
448 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
449 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
450 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
451 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
452 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
453 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
454 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
455 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
456 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
457 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
458 "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
459 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
460 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
461 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
462 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
463 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
464 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
465 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
466 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
467 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
468 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
469 "reason" => array("type" => "text", "not null" => "1"),
470 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
471 "info" => array("type" => "mediumtext", "not null" => "1"),
472 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
473 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
474 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
475 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
476 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
477 "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
480 "PRIMARY" => array("id"),
481 "uid" => array("uid"),
484 $database["conv"] = array(
486 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
487 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
488 "recips" => array("type" => "mediumtext", "not null" => "1"),
489 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
490 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
491 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
492 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
493 "subject" => array("type" => "mediumtext", "not null" => "1"),
496 "PRIMARY" => array("id"),
497 "uid" => array("uid"),
500 $database["deliverq"] = array(
502 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
503 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
504 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
505 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
508 "PRIMARY" => array("id"),
511 $database["dsprphotoq"] = array(
513 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
514 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
515 "msg" => array("type" => "mediumtext", "not null" => "1"),
516 "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
519 "PRIMARY" => array("id"),
522 $database["event"] = array(
524 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
525 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
526 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
527 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
528 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
529 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
530 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
531 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
532 "summary" => array("type" => "text", "not null" => "1"),
533 "desc" => array("type" => "text", "not null" => "1"),
534 "location" => array("type" => "text", "not null" => "1"),
535 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
536 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
537 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
538 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
539 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
540 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
541 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
542 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
545 "PRIMARY" => array("id"),
546 "uid" => array("uid"),
549 $database["fcontact"] = array(
551 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
552 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
553 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
554 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
555 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
556 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
557 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
558 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
559 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
560 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
561 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
562 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
563 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
564 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
565 "pubkey" => array("type" => "text", "not null" => "1"),
566 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
569 "PRIMARY" => array("id"),
570 "addr" => array("addr"),
573 $database["ffinder"] = array(
575 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
576 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
577 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
578 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
581 "PRIMARY" => array("id"),
584 $database["fserver"] = array(
586 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
587 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
588 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
589 "key" => array("type" => "text", "not null" => "1"),
592 "PRIMARY" => array("id"),
593 "server" => array("server"),
596 $database["fsuggest"] = array(
598 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
599 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
600 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
601 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
602 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
603 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
604 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
605 "note" => array("type" => "text", "not null" => "1"),
606 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
609 "PRIMARY" => array("id"),
612 $database["gcign"] = array(
614 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
615 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
616 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
619 "PRIMARY" => array("id"),
620 "uid" => array("uid"),
621 "gcid" => array("gcid"),
624 $database["gcontact"] = array(
626 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
627 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
628 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
629 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
630 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
631 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
633 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
634 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
635 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
636 "about" => array("type" => "text", "not null" => "1"),
637 "keywords" => array("type" => "text", "not null" => "1"),
638 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
639 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
640 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
643 "PRIMARY" => array("id"),
644 "nurl" => array("nurl"),
647 $database["glink"] = array(
649 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
650 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
651 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
652 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
653 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
654 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
657 "PRIMARY" => array("id"),
658 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
659 "gcid" => array("gcid"),
660 "zcid" => array("zcid"),
663 $database["group"] = array(
665 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
666 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
667 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
668 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
669 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
672 "PRIMARY" => array("id"),
673 "uid" => array("uid"),
676 $database["group_member"] = array(
678 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
679 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
680 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
681 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
684 "PRIMARY" => array("id"),
685 "uid_gid_contactid" => array("uid","gid","contact-id"),
688 $database["guid"] = array(
690 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
691 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
692 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
693 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
694 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
697 "PRIMARY" => array("id"),
698 "guid" => array("guid"),
699 "plink" => array("plink"),
700 "uri" => array("uri"),
703 $database["hook"] = array(
705 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
706 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
707 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
708 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
709 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
712 "PRIMARY" => array("id"),
713 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
716 $database["intro"] = array(
718 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
719 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
720 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
721 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
722 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
723 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
724 "note" => array("type" => "text", "not null" => "1"),
725 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
726 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
727 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
728 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
731 "PRIMARY" => array("id"),
734 $database["item"] = array(
736 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
737 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
740 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
741 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
742 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
743 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
744 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
745 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
749 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
750 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
751 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
752 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
753 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "body" => array("type" => "mediumtext", "not null" => "1"),
761 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
762 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
763 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
764 "object" => array("type" => "text", "not null" => "1"),
765 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
766 "target" => array("type" => "text", "not null" => "1"),
767 "postopts" => array("type" => "text", "not null" => "1"),
768 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
769 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
770 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
771 "tag" => array("type" => "mediumtext", "not null" => "1"),
772 "attach" => array("type" => "mediumtext", "not null" => "1"),
773 "inform" => array("type" => "mediumtext", "not null" => "1"),
774 "file" => array("type" => "mediumtext", "not null" => "1"),
775 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
776 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
777 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
778 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
779 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
780 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
781 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
783 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
784 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
785 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
786 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
787 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
789 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
790 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
792 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
793 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
794 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
795 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
796 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
797 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
800 "PRIMARY" => array("id"),
801 "guid" => array("guid"),
802 "uri" => array("uri"),
803 "parent" => array("parent"),
804 "parent-uri" => array("parent-uri"),
805 "extid" => array("extid"),
806 "uid_id" => array("uid","id"),
807 "uid_created" => array("uid","created"),
808 "uid_unseen" => array("uid","unseen"),
809 "uid_network_received" => array("uid","network","received"),
810 "uid_received" => array("uid","received"),
811 "uid_network_commented" => array("uid","network","commented"),
812 "uid_commented" => array("uid","commented"),
813 "uid_title" => array("uid","title"),
814 "uid_thrparent" => array("uid","thr-parent"),
815 "uid_parenturi" => array("uid","parent-uri"),
816 "uid_contactid_created" => array("uid","contact-id","created"),
817 "wall_body" => array("wall","body(6)"),
818 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
819 "uid_uri" => array("uid","uri"),
820 "uid_wall_created" => array("uid","wall","created"),
821 "resource-id" => array("resource-id"),
822 "uid_type" => array("uid","type"),
823 "uid_starred" => array("uid","starred"),
824 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
825 "uid_wall_parent_created" => array("uid","wall","parent","created"),
826 "uid_type_changed" => array("uid","type","changed"),
827 "contactid_verb" => array("contact-id","verb"),
828 "deleted_changed" => array("deleted","changed"),
829 "uid_wall_changed" => array("uid","wall","changed"),
830 "uid_eventid" => array("uid","event-id"),
831 "uid_authorlink" => array("uid","author-link"),
832 "uid_ownerlink" => array("uid","owner-link"),
835 $database["item_id"] = array(
837 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
838 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
839 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
840 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
841 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
844 "PRIMARY" => array("id"),
845 "uid" => array("uid"),
846 "sid" => array("sid"),
847 "service" => array("service"),
848 "iid" => array("iid"),
851 $database["locks"] = array(
853 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
854 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
855 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
856 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
859 "PRIMARY" => array("id"),
862 $database["mail"] = array(
864 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
865 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
866 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
867 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
868 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
869 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
872 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
873 "body" => array("type" => "mediumtext", "not null" => "1"),
874 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
875 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
876 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
877 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
878 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
879 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
880 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
883 "PRIMARY" => array("id"),
884 "uid" => array("uid"),
885 "guid" => array("guid"),
886 "convid" => array("convid"),
887 "reply" => array("reply"),
888 "uri" => array("uri"),
889 "parent-uri" => array("parent-uri"),
892 $database["mailacct"] = array(
894 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
895 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
896 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
897 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
898 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
899 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "pass" => array("type" => "text", "not null" => "1"),
902 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
903 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
904 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
905 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
906 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
909 "PRIMARY" => array("id"),
912 $database["manage"] = array(
914 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
915 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
916 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
919 "PRIMARY" => array("id"),
920 "uid_mid" => array("uid","mid"),
923 $database["notify"] = array(
925 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
926 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
927 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
928 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
929 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
930 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
931 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
932 "msg" => array("type" => "mediumtext", "not null" => "1"),
933 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
934 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
935 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
936 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
937 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
938 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
939 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
942 "PRIMARY" => array("id"),
943 "uid" => array("uid"),
946 $database["notify-threads"] = array(
948 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
949 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
950 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
951 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
952 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
955 "PRIMARY" => array("id"),
956 "master-parent-item" => array("master-parent-item"),
957 "receiver-uid" => array("receiver-uid"),
960 $database["pconfig"] = array(
962 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
963 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
964 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
965 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
966 "v" => array("type" => "mediumtext", "not null" => "1"),
969 "PRIMARY" => array("id"),
970 "uid_cat_k" => array("uid","cat(30)","k(30)"),
973 $database["photo"] = array(
975 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
976 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
977 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
978 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
979 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
980 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
981 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
982 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
983 "desc" => array("type" => "text", "not null" => "1"),
984 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
985 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
986 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
987 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
988 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
989 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
990 "data" => array("type" => "mediumblob", "not null" => "1"),
991 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
992 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
993 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
994 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
995 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
996 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
999 "PRIMARY" => array("id"),
1000 "uid" => array("uid"),
1001 "resource-id" => array("resource-id"),
1002 "guid" => array("guid"),
1005 $database["poll"] = array(
1007 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1008 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1009 "q0" => array("type" => "mediumtext", "not null" => "1"),
1010 "q1" => array("type" => "mediumtext", "not null" => "1"),
1011 "q2" => array("type" => "mediumtext", "not null" => "1"),
1012 "q3" => array("type" => "mediumtext", "not null" => "1"),
1013 "q4" => array("type" => "mediumtext", "not null" => "1"),
1014 "q5" => array("type" => "mediumtext", "not null" => "1"),
1015 "q6" => array("type" => "mediumtext", "not null" => "1"),
1016 "q7" => array("type" => "mediumtext", "not null" => "1"),
1017 "q8" => array("type" => "mediumtext", "not null" => "1"),
1018 "q9" => array("type" => "mediumtext", "not null" => "1"),
1021 "PRIMARY" => array("id"),
1022 "uid" => array("uid"),
1025 $database["poll_result"] = array(
1027 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1028 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1029 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1032 "PRIMARY" => array("id"),
1033 "poll_id" => array("poll_id"),
1034 "choice" => array("choice"),
1037 $database["profile"] = array(
1039 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1040 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1041 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1042 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1043 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1044 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1045 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1047 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1050 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1051 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1052 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1053 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1054 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1055 "with" => array("type" => "text", "not null" => "1"),
1056 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1057 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1058 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1059 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1060 "pub_keywords" => array("type" => "text", "not null" => "1"),
1061 "prv_keywords" => array("type" => "text", "not null" => "1"),
1062 "likes" => array("type" => "text", "not null" => "1"),
1063 "dislikes" => array("type" => "text", "not null" => "1"),
1064 "about" => array("type" => "text", "not null" => "1"),
1065 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1066 "music" => array("type" => "text", "not null" => "1"),
1067 "book" => array("type" => "text", "not null" => "1"),
1068 "tv" => array("type" => "text", "not null" => "1"),
1069 "film" => array("type" => "text", "not null" => "1"),
1070 "interest" => array("type" => "text", "not null" => "1"),
1071 "romance" => array("type" => "text", "not null" => "1"),
1072 "work" => array("type" => "text", "not null" => "1"),
1073 "education" => array("type" => "text", "not null" => "1"),
1074 "contact" => array("type" => "text", "not null" => "1"),
1075 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1076 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1077 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1078 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1079 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1082 "PRIMARY" => array("id"),
1083 "hometown" => array("hometown"),
1086 $database["profile_check"] = array(
1088 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1089 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1090 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1091 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1092 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1096 "PRIMARY" => array("id"),
1099 $database["push_subscriber"] = array(
1101 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1102 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1103 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1107 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1108 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1111 "PRIMARY" => array("id"),
1114 $database["queue"] = array(
1116 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1117 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1118 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1119 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1120 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1121 "content" => array("type" => "mediumtext", "not null" => "1"),
1122 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1125 "PRIMARY" => array("id"),
1126 "cid" => array("cid"),
1127 "created" => array("created"),
1128 "last" => array("last"),
1129 "network" => array("network"),
1130 "batch" => array("batch"),
1133 $database["register"] = array(
1135 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1136 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1137 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1138 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1139 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1140 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1143 "PRIMARY" => array("id"),
1146 $database["search"] = array(
1148 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1149 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1150 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1153 "PRIMARY" => array("id"),
1154 "uid" => array("uid"),
1155 "term" => array("term"),
1158 $database["session"] = array(
1160 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1161 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1162 "data" => array("type" => "text", "not null" => "1"),
1163 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1166 "PRIMARY" => array("id"),
1167 "sid" => array("sid"),
1168 "expire" => array("expire"),
1171 $database["sign"] = array(
1173 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1174 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1175 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1176 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1177 "signature" => array("type" => "text", "not null" => "1"),
1178 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1181 "PRIMARY" => array("id"),
1182 "iid" => array("iid"),
1183 "retract_iid" => array("retract_iid"),
1186 $database["spam"] = 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 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1191 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1192 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1193 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1196 "PRIMARY" => array("id"),
1197 "uid" => array("uid"),
1198 "spam" => array("spam"),
1199 "ham" => array("ham"),
1200 "term" => array("term"),
1203 $database["term"] = array(
1205 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1206 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1207 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1208 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1209 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1210 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1211 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1212 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1213 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1214 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1215 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1216 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1219 "PRIMARY" => array("tid"),
1220 "oid_otype_type_term" => array("oid","otype","type","term"),
1221 "uid_term_tid" => array("uid","term","tid"),
1222 "type_term" => array("type","term"),
1223 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1224 "otype_type_term_tid" => array("otype","type","term","tid"),
1225 "guid" => array("guid"),
1228 $database["thread"] = array(
1230 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1231 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1232 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1233 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1234 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1235 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1236 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1237 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1238 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1239 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1240 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1241 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1242 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1243 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1244 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1245 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1246 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1247 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1248 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1249 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1250 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1251 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1252 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1255 "PRIMARY" => array("iid"),
1256 "created" => array("created"),
1257 "commented" => array("commented"),
1258 "uid_network_commented" => array("uid","network","commented"),
1259 "uid_network_created" => array("uid","network","created"),
1260 "uid_contactid_commented" => array("uid","contact-id","commented"),
1261 "uid_contactid_created" => array("uid","contact-id","created"),
1262 "wall_private_received" => array("wall","private","received"),
1263 "uid_created" => array("uid","created"),
1264 "uid_commented" => array("uid","commented"),
1267 $database["tokens"] = array(
1269 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1270 "secret" => array("type" => "text", "not null" => "1"),
1271 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1272 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1273 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1274 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1277 "PRIMARY" => array("id"),
1280 $database["unique_contacts"] = array(
1282 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1283 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1284 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1285 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1286 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1287 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1288 "about" => array("type" => "text", "not null" => "1"),
1291 "PRIMARY" => array("id"),
1292 "url" => array("url"),
1295 $database["user"] = array(
1297 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1298 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1299 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1300 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1301 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1302 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1303 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1304 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1305 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1306 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1307 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1308 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1309 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1310 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1311 "pubkey" => array("type" => "text", "not null" => "1"),
1312 "prvkey" => array("type" => "text", "not null" => "1"),
1313 "spubkey" => array("type" => "text", "not null" => "1"),
1314 "sprvkey" => array("type" => "text", "not null" => "1"),
1315 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1316 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1317 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1318 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1319 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1320 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1321 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1322 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1323 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1324 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1325 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1326 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1327 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1328 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1329 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1330 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1331 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1332 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1333 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1334 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1335 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1336 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1337 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1338 "openidserver" => array("type" => "text", "not null" => "1"),
1341 "PRIMARY" => array("uid"),
1342 "nickname" => array("nickname"),
1345 $database["userd"] = array(
1347 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1348 "username" => array("type" => "varchar(255)", "not null" => "1"),
1351 "PRIMARY" => array("id"),
1352 "username" => array("username"),
1361 * run from command line
1363 function dbstructure_run(&$argv, &$argc) {
1371 @include(".htconfig.php");
1372 require_once("include/dba.php");
1373 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1374 unset($db_host, $db_user, $db_pass, $db_data);
1380 update_structure(true, true);
1383 print_structure(db_definition());
1390 echo $argv[0]." <command>\n";
1393 echo "update update database schema\n";
1394 echo "dumpsql dump database schema\n";
1402 if (array_search(__file__,get_included_files())===0){
1403 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);