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 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
634 "about" => array("type" => "text", "not null" => "1"),
635 "keywords" => array("type" => "text", "not null" => "1"),
636 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
637 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
638 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
641 "PRIMARY" => array("id"),
642 "nurl" => array("nurl"),
645 $database["glink"] = array(
647 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
648 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
649 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
650 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
651 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
652 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
655 "PRIMARY" => array("id"),
656 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
657 "gcid" => array("gcid"),
658 "zcid" => array("zcid"),
661 $database["group"] = array(
663 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
664 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
665 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
666 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
667 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
670 "PRIMARY" => array("id"),
671 "uid" => array("uid"),
674 $database["group_member"] = array(
676 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
677 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
678 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
679 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
682 "PRIMARY" => array("id"),
683 "uid_gid_contactid" => array("uid","gid","contact-id"),
686 $database["guid"] = array(
688 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
689 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
690 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
691 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
692 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
695 "PRIMARY" => array("id"),
696 "guid" => array("guid"),
697 "plink" => array("plink"),
698 "uri" => array("uri"),
701 $database["hook"] = array(
703 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
704 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
705 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
706 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
707 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
710 "PRIMARY" => array("id"),
711 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
714 $database["intro"] = array(
716 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
717 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
718 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
719 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
720 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
721 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
722 "note" => array("type" => "text", "not null" => "1"),
723 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
724 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
725 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
726 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
729 "PRIMARY" => array("id"),
732 $database["item"] = array(
734 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
735 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
738 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
739 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
741 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
742 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
743 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
747 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
748 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
749 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
750 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
751 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
753 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758 "body" => array("type" => "mediumtext", "not null" => "1"),
759 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
761 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
762 "object" => array("type" => "text", "not null" => "1"),
763 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
764 "target" => array("type" => "text", "not null" => "1"),
765 "postopts" => array("type" => "text", "not null" => "1"),
766 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
767 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
768 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
769 "tag" => array("type" => "mediumtext", "not null" => "1"),
770 "attach" => array("type" => "mediumtext", "not null" => "1"),
771 "inform" => array("type" => "mediumtext", "not null" => "1"),
772 "file" => array("type" => "mediumtext", "not null" => "1"),
773 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
774 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
775 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
776 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
777 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
778 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
779 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
780 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
781 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
783 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
784 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
785 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
786 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
787 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
790 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
791 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
792 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
793 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
794 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
795 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
798 "PRIMARY" => array("id"),
799 "guid" => array("guid"),
800 "uri" => array("uri"),
801 "parent" => array("parent"),
802 "parent-uri" => array("parent-uri"),
803 "extid" => array("extid"),
804 "uid_id" => array("uid","id"),
805 "uid_created" => array("uid","created"),
806 "uid_unseen" => array("uid","unseen"),
807 "uid_network_received" => array("uid","network","received"),
808 "uid_received" => array("uid","received"),
809 "uid_network_commented" => array("uid","network","commented"),
810 "uid_commented" => array("uid","commented"),
811 "uid_title" => array("uid","title"),
812 "uid_thrparent" => array("uid","thr-parent"),
813 "uid_parenturi" => array("uid","parent-uri"),
814 "uid_contactid_created" => array("uid","contact-id","created"),
815 "wall_body" => array("wall","body(6)"),
816 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
817 "uid_uri" => array("uid","uri"),
818 "uid_wall_created" => array("uid","wall","created"),
819 "resource-id" => array("resource-id"),
820 "uid_type" => array("uid","type"),
821 "uid_starred" => array("uid","starred"),
822 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
823 "uid_wall_parent_created" => array("uid","wall","parent","created"),
824 "uid_type_changed" => array("uid","type","changed"),
825 "contactid_verb" => array("contact-id","verb"),
826 "deleted_changed" => array("deleted","changed"),
827 "uid_wall_changed" => array("uid","wall","changed"),
828 "uid_eventid" => array("uid","event-id"),
829 "uid_authorlink" => array("uid","author-link"),
830 "uid_ownerlink" => array("uid","owner-link"),
833 $database["item_id"] = array(
835 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
836 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
837 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
838 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
839 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
842 "PRIMARY" => array("id"),
843 "uid" => array("uid"),
844 "sid" => array("sid"),
845 "service" => array("service"),
846 "iid" => array("iid"),
849 $database["locks"] = array(
851 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
852 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
853 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
854 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
857 "PRIMARY" => array("id"),
860 $database["mail"] = array(
862 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
863 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
864 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
865 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
866 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
867 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
868 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
869 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
870 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "body" => array("type" => "mediumtext", "not null" => "1"),
872 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
873 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
874 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
875 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
876 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
877 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
878 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
881 "PRIMARY" => array("id"),
882 "uid" => array("uid"),
883 "guid" => array("guid"),
884 "convid" => array("convid"),
885 "reply" => array("reply"),
886 "uri" => array("uri"),
887 "parent-uri" => array("parent-uri"),
890 $database["mailacct"] = array(
892 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
893 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
894 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
895 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
896 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
897 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
898 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
899 "pass" => array("type" => "text", "not null" => "1"),
900 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
902 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
903 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
904 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
907 "PRIMARY" => array("id"),
910 $database["manage"] = array(
912 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
913 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
914 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
917 "PRIMARY" => array("id"),
918 "uid_mid" => array("uid","mid"),
921 $database["notify"] = array(
923 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
924 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
925 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
926 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
927 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
928 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
929 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
930 "msg" => array("type" => "mediumtext", "not null" => "1"),
931 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
932 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
933 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
934 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
935 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
936 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
937 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
940 "PRIMARY" => array("id"),
941 "uid" => array("uid"),
944 $database["notify-threads"] = array(
946 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
947 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
948 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
949 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
950 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
953 "PRIMARY" => array("id"),
954 "master-parent-item" => array("master-parent-item"),
955 "receiver-uid" => array("receiver-uid"),
958 $database["pconfig"] = array(
960 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
961 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
962 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
963 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
964 "v" => array("type" => "mediumtext", "not null" => "1"),
967 "PRIMARY" => array("id"),
968 "uid_cat_k" => array("uid","cat(30)","k(30)"),
971 $database["photo"] = array(
973 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
974 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
975 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
976 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
977 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
978 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
979 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
980 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
981 "desc" => array("type" => "text", "not null" => "1"),
982 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
983 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
984 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
985 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
986 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
987 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
988 "data" => array("type" => "mediumblob", "not null" => "1"),
989 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
990 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
991 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
992 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
993 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
994 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
997 "PRIMARY" => array("id"),
998 "uid" => array("uid"),
999 "resource-id" => array("resource-id"),
1000 "guid" => array("guid"),
1003 $database["poll"] = array(
1005 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1006 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1007 "q0" => array("type" => "mediumtext", "not null" => "1"),
1008 "q1" => array("type" => "mediumtext", "not null" => "1"),
1009 "q2" => array("type" => "mediumtext", "not null" => "1"),
1010 "q3" => array("type" => "mediumtext", "not null" => "1"),
1011 "q4" => array("type" => "mediumtext", "not null" => "1"),
1012 "q5" => array("type" => "mediumtext", "not null" => "1"),
1013 "q6" => array("type" => "mediumtext", "not null" => "1"),
1014 "q7" => array("type" => "mediumtext", "not null" => "1"),
1015 "q8" => array("type" => "mediumtext", "not null" => "1"),
1016 "q9" => array("type" => "mediumtext", "not null" => "1"),
1019 "PRIMARY" => array("id"),
1020 "uid" => array("uid"),
1023 $database["poll_result"] = array(
1025 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1026 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1027 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1030 "PRIMARY" => array("id"),
1031 "poll_id" => array("poll_id"),
1032 "choice" => array("choice"),
1035 $database["profile"] = array(
1037 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1038 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1039 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1040 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1041 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1042 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1045 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1049 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1050 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1051 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1052 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1053 "with" => array("type" => "text", "not null" => "1"),
1054 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1055 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1056 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1057 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1058 "pub_keywords" => array("type" => "text", "not null" => "1"),
1059 "prv_keywords" => array("type" => "text", "not null" => "1"),
1060 "likes" => array("type" => "text", "not null" => "1"),
1061 "dislikes" => array("type" => "text", "not null" => "1"),
1062 "about" => array("type" => "text", "not null" => "1"),
1063 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1064 "music" => array("type" => "text", "not null" => "1"),
1065 "book" => array("type" => "text", "not null" => "1"),
1066 "tv" => array("type" => "text", "not null" => "1"),
1067 "film" => array("type" => "text", "not null" => "1"),
1068 "interest" => array("type" => "text", "not null" => "1"),
1069 "romance" => array("type" => "text", "not null" => "1"),
1070 "work" => array("type" => "text", "not null" => "1"),
1071 "education" => array("type" => "text", "not null" => "1"),
1072 "contact" => array("type" => "text", "not null" => "1"),
1073 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1074 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1075 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1076 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1077 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1080 "PRIMARY" => array("id"),
1081 "hometown" => array("hometown"),
1084 $database["profile_check"] = array(
1086 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1087 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1088 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1089 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1090 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1091 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1094 "PRIMARY" => array("id"),
1097 $database["push_subscriber"] = array(
1099 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1100 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1101 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1102 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1105 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1106 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1109 "PRIMARY" => array("id"),
1112 $database["queue"] = array(
1114 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1115 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1116 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1117 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1118 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1119 "content" => array("type" => "mediumtext", "not null" => "1"),
1120 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1123 "PRIMARY" => array("id"),
1124 "cid" => array("cid"),
1125 "created" => array("created"),
1126 "last" => array("last"),
1127 "network" => array("network"),
1128 "batch" => array("batch"),
1131 $database["register"] = array(
1133 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1134 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1135 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1136 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1137 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1138 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1141 "PRIMARY" => array("id"),
1144 $database["search"] = array(
1146 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1147 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1148 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1151 "PRIMARY" => array("id"),
1152 "uid" => array("uid"),
1153 "term" => array("term"),
1156 $database["session"] = array(
1158 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1159 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1160 "data" => array("type" => "text", "not null" => "1"),
1161 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1164 "PRIMARY" => array("id"),
1165 "sid" => array("sid"),
1166 "expire" => array("expire"),
1169 $database["sign"] = array(
1171 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1172 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1173 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1174 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1175 "signature" => array("type" => "text", "not null" => "1"),
1176 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1179 "PRIMARY" => array("id"),
1180 "iid" => array("iid"),
1181 "retract_iid" => array("retract_iid"),
1184 $database["spam"] = array(
1186 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1187 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1188 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1189 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1190 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1191 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1194 "PRIMARY" => array("id"),
1195 "uid" => array("uid"),
1196 "spam" => array("spam"),
1197 "ham" => array("ham"),
1198 "term" => array("term"),
1201 $database["term"] = array(
1203 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1204 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1205 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1206 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1207 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1208 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1209 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1210 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1211 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1212 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1213 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1214 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1217 "PRIMARY" => array("tid"),
1218 "oid_otype_type_term" => array("oid","otype","type","term"),
1219 "uid_term_tid" => array("uid","term","tid"),
1220 "type_term" => array("type","term"),
1221 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1222 "otype_type_term_tid" => array("otype","type","term","tid"),
1223 "guid" => array("guid"),
1226 $database["thread"] = array(
1228 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1229 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1230 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1231 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1232 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1233 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1234 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1235 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1236 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1237 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1238 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1239 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1240 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1241 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1242 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1243 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1244 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1245 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1246 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1247 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1248 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1249 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1250 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1253 "PRIMARY" => array("iid"),
1254 "created" => array("created"),
1255 "commented" => array("commented"),
1256 "uid_network_commented" => array("uid","network","commented"),
1257 "uid_network_created" => array("uid","network","created"),
1258 "uid_contactid_commented" => array("uid","contact-id","commented"),
1259 "uid_contactid_created" => array("uid","contact-id","created"),
1260 "wall_private_received" => array("wall","private","received"),
1261 "uid_created" => array("uid","created"),
1262 "uid_commented" => array("uid","commented"),
1265 $database["tokens"] = array(
1267 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1268 "secret" => array("type" => "text", "not null" => "1"),
1269 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1270 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1271 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1272 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1275 "PRIMARY" => array("id"),
1278 $database["unique_contacts"] = array(
1280 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1281 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1282 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1283 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1284 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1285 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1286 "about" => array("type" => "text", "not null" => "1"),
1289 "PRIMARY" => array("id"),
1290 "url" => array("url"),
1293 $database["user"] = array(
1295 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1296 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1297 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1298 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1299 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1300 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1301 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1302 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1303 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1304 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1305 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1306 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1307 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1308 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1309 "pubkey" => array("type" => "text", "not null" => "1"),
1310 "prvkey" => array("type" => "text", "not null" => "1"),
1311 "spubkey" => array("type" => "text", "not null" => "1"),
1312 "sprvkey" => array("type" => "text", "not null" => "1"),
1313 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1314 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1315 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1316 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1317 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1318 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1319 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1320 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1321 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1322 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1323 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1324 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1325 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1326 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1327 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1328 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1329 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1330 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1331 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1332 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1333 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1334 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1335 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1336 "openidserver" => array("type" => "text", "not null" => "1"),
1339 "PRIMARY" => array("uid"),
1340 "nickname" => array("nickname"),
1343 $database["userd"] = array(
1345 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1346 "username" => array("type" => "varchar(255)", "not null" => "1"),
1349 "PRIMARY" => array("id"),
1350 "username" => array("username"),
1359 * run from command line
1361 function dbstructure_run(&$argv, &$argc) {
1369 @include(".htconfig.php");
1370 require_once("include/dba.php");
1371 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1372 unset($db_host, $db_user, $db_pass, $db_data);
1378 update_structure(true, true);
1381 print_structure(db_definition());
1388 echo $argv[0]." <command>\n";
1391 echo "update update database schema\n";
1392 echo "dumpsql dump database schema\n";
1400 if (array_search(__file__,get_included_files())===0){
1401 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);