3 use \Friendica\Core\Config;
5 require_once("boot.php");
6 require_once("include/text.php");
8 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
11 * send the email and do what is needed to do on update fails
13 * @param update_id (int) number of failed update
14 * @param error_message (str) error message
16 function update_fail($update_id, $error_message){
17 //send the administrators an e-mail
18 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
19 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
24 if (!dbm::is_result($adminlist)) {
25 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
31 // every admin could had different language
32 foreach ($adminlist as $admin) {
33 $lang = (($admin['language'])?$admin['language']:'en');
36 $preamble = deindent(t("
37 The friendica developers released update %s recently,
38 but when I tried to install it, something went terribly wrong.
39 This needs to be fixed soon and I can't do it alone. Please contact a
40 friendica developer if you can not help me on your own. My database might be invalid."));
41 $body = t("The error message is\n[pre]%s[/pre]");
42 $preamble = sprintf($preamble, $update_id);
43 $body = sprintf($body, $error_message);
46 'type' => "SYSTEM_EMAIL",
47 'to_email' => $admin['email'],
48 'preamble' => $preamble,
58 $email_tpl = get_intltext_template("update_fail_eml.tpl");
59 $email_msg = replace_macros($email_tpl, array(
60 '$sitename' => $a->config['sitename'],
61 '$siteurl' => App::get_baseurl(),
62 '$update' => DB_UPDATE_VERSION,
63 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
65 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
66 require_once('include/email.php');
67 $subject = email_header_encode($subject,'UTF-8');
68 mail($a->config['admin_email'], $subject, $email_msg,
69 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
70 .'Content-type: text/plain; charset=UTF-8'."\n"
71 .'Content-transfer-encoding: 8bit');
74 logger("CRITICAL: Database structure update failed: ".$retval);
78 function table_structure($table) {
79 $structures = q("DESCRIBE `%s`", $table);
81 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
83 $indexes = q("SHOW INDEX FROM `%s`", $table);
85 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
87 if (dbm::is_result($table_status)) {
88 $table_status = $table_status[0];
90 $table_status = array();
96 if (dbm::is_result($indexes))
97 foreach ($indexes AS $index) {
98 if ($index["Index_type"] == "FULLTEXT") {
102 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
103 $indexdata[$index["Key_name"]] = array('UNIQUE');
106 $column = $index["Column_name"];
107 // On utf8mb4 a varchar index can only have a length of 191
108 // To avoid the need to add this to every index definition we just ignore it here.
109 // Exception are primary indexes
110 // Since there are some combindex primary indexes we use the limit of 180 here.
111 if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) {
112 $column .= "(".$index["Sub_part"].")";
115 $indexdata[$index["Key_name"]][] = $column;
117 if (dbm::is_result($structures)) {
118 foreach ($structures AS $field) {
119 $fielddata[$field["Field"]]["type"] = $field["Type"];
120 if ($field["Null"] == "NO") {
121 $fielddata[$field["Field"]]["not null"] = true;
124 if (isset($field["Default"])) {
125 $fielddata[$field["Field"]]["default"] = $field["Default"];
128 if ($field["Extra"] != "") {
129 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
132 if ($field["Key"] == "PRI") {
133 $fielddata[$field["Field"]]["primary"] = true;
137 if (dbm::is_result($full_columns)) {
138 foreach ($full_columns AS $column) {
139 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
143 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
146 function print_structure($database) {
147 echo "-- ------------------------------------------\n";
148 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
149 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
150 echo "-- ------------------------------------------\n\n\n";
151 foreach ($database AS $name => $structure) {
153 echo "-- TABLE $name\n";
155 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
161 function update_structure($verbose, $action, $tables=null, $definition=null) {
165 Config::set('system', 'maintenance', 1);
166 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
171 logger('updating structure', LOGGER_DEBUG);
173 // Get the current structure
176 if (is_null($tables)) {
177 $tables = q("SHOW TABLES");
180 if (dbm::is_result($tables)) {
181 foreach ($tables AS $table) {
182 $table = current($table);
184 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
185 $database[$table] = table_structure($table);
189 // Get the definition
190 if (is_null($definition)) {
191 $definition = db_definition();
194 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
195 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
196 !(strpos($db->server_info(), 'MariaDB') !== false)) {
203 foreach ($definition AS $name => $structure) {
204 $is_new_table = False;
207 if (!isset($database[$name])) {
208 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
209 if (!dbm::is_result($r)) {
210 $errors .= t('Errors encountered creating database tables.').$name.EOL;
212 $is_new_table = True;
217 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
218 if (isset($database[$name]["indexes"][$indexname])) {
219 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
221 $current_index_definition = "__NOT_SET__";
223 $new_index_definition = implode(",",$fieldnames);
224 if ($current_index_definition != $new_index_definition) {
225 if ($fieldnames[0] == "UNIQUE") {
228 $temp_name = "temp-".$name;
235 * Drop the index if it isn't present in the definition
236 * or the definition differ from current status
237 * and index name doesn't start with "local_"
239 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
240 $current_index_definition = implode(",",$fieldnames);
241 if (isset($structure["indexes"][$indexname])) {
242 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
244 $new_index_definition = "__NOT_SET__";
246 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
247 $sql2=db_drop_index($indexname);
249 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
255 // Compare the field structure field by field
256 foreach ($structure["fields"] AS $fieldname => $parameters) {
257 if (!isset($database[$name]["fields"][$fieldname])) {
258 $sql2=db_add_table_field($fieldname, $parameters);
260 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
265 // Compare the field definition
266 $field_definition = $database[$name]["fields"][$fieldname];
268 // Define the default collation if not given
269 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
270 $parameters['Collation'] = 'utf8mb4_general_ci';
272 $parameters['Collation'] = null;
275 $current_field_definition = implode(",", $field_definition);
276 $new_field_definition = implode(",", $parameters);
277 if ($current_field_definition != $new_field_definition) {
278 $sql2 = db_modify_table_field($fieldname, $parameters);
280 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
290 * Create the index if the index don't exists in database
291 * or the definition differ from the current status.
292 * Don't create keys if table is new
294 if (!$is_new_table) {
295 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
296 if (isset($database[$name]["indexes"][$indexname])) {
297 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
299 $current_index_definition = "__NOT_SET__";
301 $new_index_definition = implode(",",$fieldnames);
302 if ($current_index_definition != $new_index_definition) {
303 $sql2 = db_create_index($indexname, $fieldnames);
305 // Fetch the "group by" fields for unique indexes
306 if ($fieldnames[0] == "UNIQUE") {
307 $group_by = db_group_by($indexname, $fieldnames);
311 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
319 if (isset($database[$name]["table_status"]["Collation"])) {
320 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
321 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
324 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
335 // Ensure index conversion to unique removes duplicates
338 echo "SET session old_alter_table=1;\n";
340 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
348 echo "SET session old_alter_table=0;\n";
350 echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
351 echo "DROP TABLE `".$name."`;\n";
352 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
358 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
360 // Ensure index conversion to unique removes duplicates
363 $db->q("SET session old_alter_table=1;");
365 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
366 if (!dbm::is_result($r)) {
367 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
374 if (!dbm::is_result($r))
375 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
379 $db->q("SET session old_alter_table=0;");
381 $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
382 if (!dbm::is_result($r)) {
383 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
386 $r = $db->q("DROP TABLE `".$name."`;");
387 if (!dbm::is_result($r)) {
388 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
391 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
392 if (!dbm::is_result($r)) {
393 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
403 Config::set('system', 'maintenance', 0);
404 Config::set('system', 'maintenance_reason', '');
410 function db_field_command($parameters, $create = true) {
411 $fieldstruct = $parameters["type"];
413 if (!is_null($parameters["Collation"])) {
414 $fieldstruct .= " COLLATE ".$parameters["Collation"];
417 if ($parameters["not null"])
418 $fieldstruct .= " NOT NULL";
420 if (isset($parameters["default"])){
421 if (strpos(strtolower($parameters["type"]),"int")!==false) {
422 $fieldstruct .= " DEFAULT ".$parameters["default"];
424 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
427 if ($parameters["extra"] != "")
428 $fieldstruct .= " ".$parameters["extra"];
430 /*if (($parameters["primary"] != "") AND $create)
431 $fieldstruct .= " PRIMARY KEY";*/
433 return($fieldstruct);
436 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
444 $primary_keys = array();
445 foreach($fields AS $fieldname => $field) {
446 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
447 if (x($field,'primary') and $field['primary']!=''){
448 $primary_keys[] = $fieldname;
452 if (!is_null($indexes)) {
453 foreach ($indexes AS $indexname => $fieldnames) {
454 $sql_index = db_create_index($indexname, $fieldnames, "");
455 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
459 $sql = implode(",\n\t", $sql_rows);
461 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
471 function db_add_table_field($fieldname, $parameters) {
472 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
476 function db_modify_table_field($fieldname, $parameters) {
477 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
481 function db_drop_index($indexname) {
482 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
486 function db_create_index($indexname, $fieldnames, $method="ADD") {
488 $method = strtoupper(trim($method));
489 if ($method!="" && $method!="ADD") {
490 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
494 if ($fieldnames[0] == "UNIQUE") {
495 array_shift($fieldnames);
496 $method .= ' UNIQUE';
500 foreach ($fieldnames AS $fieldname) {
504 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
505 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
507 $names .= "`".dbesc($fieldname)."`";
511 if ($indexname == "PRIMARY") {
512 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
516 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
520 function db_group_by($indexname, $fieldnames) {
522 if ($fieldnames[0] != "UNIQUE") {
526 array_shift($fieldnames);
529 foreach ($fieldnames AS $fieldname) {
533 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
534 $names .= "`".dbesc($matches[1])."`";
536 $names .= "`".dbesc($fieldname)."`";
540 $sql = sprintf(" GROUP BY %s", $names);
544 function db_definition() {
548 $database["addon"] = array(
550 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
551 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
552 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
553 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
554 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
555 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
556 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
559 "PRIMARY" => array("id"),
560 "name" => array("UNIQUE", "name"),
563 $database["attach"] = array(
565 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
566 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
567 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
568 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
569 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
570 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
571 "data" => array("type" => "longblob", "not null" => "1"),
572 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
573 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
574 "allow_cid" => array("type" => "mediumtext"),
575 "allow_gid" => array("type" => "mediumtext"),
576 "deny_cid" => array("type" => "mediumtext"),
577 "deny_gid" => array("type" => "mediumtext"),
580 "PRIMARY" => array("id"),
583 $database["auth_codes"] = array(
585 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
586 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
587 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
588 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
589 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
592 "PRIMARY" => array("id"),
595 $database["cache"] = array(
597 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
598 "v" => array("type" => "mediumtext"),
599 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
600 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
603 "PRIMARY" => array("k"),
604 "expire_mode_updated" => array("expire_mode", "updated"),
607 $database["challenge"] = array(
609 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
610 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
611 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
612 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
613 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
614 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
617 "PRIMARY" => array("id"),
620 $database["clients"] = array(
622 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
623 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
624 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
625 "name" => array("type" => "text"),
626 "icon" => array("type" => "text"),
627 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
630 "PRIMARY" => array("client_id"),
633 $database["config"] = array(
635 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
636 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
637 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
638 "v" => array("type" => "mediumtext"),
641 "PRIMARY" => array("id"),
642 "cat_k" => array("UNIQUE", "cat", "k"),
645 $database["contact"] = array(
647 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
648 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
649 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
650 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
651 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
652 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
653 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
654 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
655 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
656 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
657 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
658 "about" => array("type" => "text"),
659 "keywords" => array("type" => "text"),
660 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
661 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
662 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
663 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
664 "photo" => array("type" => "text"),
665 "thumb" => array("type" => "text"),
666 "micro" => array("type" => "text"),
667 "site-pubkey" => array("type" => "text"),
668 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
669 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
670 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
671 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
672 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
673 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
674 "pubkey" => array("type" => "text"),
675 "prvkey" => array("type" => "text"),
676 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
677 "request" => array("type" => "text"),
678 "notify" => array("type" => "text"),
679 "poll" => array("type" => "text"),
680 "confirm" => array("type" => "text"),
681 "poco" => array("type" => "text"),
682 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
683 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
684 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
685 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
686 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
687 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
688 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
689 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
690 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
691 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
692 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
693 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
694 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
695 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
696 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
697 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
698 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
699 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
700 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
701 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
702 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
703 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
704 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
705 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
706 "reason" => array("type" => "text"),
707 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
708 "info" => array("type" => "mediumtext"),
709 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
710 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
711 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
712 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
713 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
714 "ffi_keyword_blacklist" => array("type" => "text"),
717 "PRIMARY" => array("id"),
718 "uid_name" => array("uid", "name"),
719 "self_uid" => array("self", "uid"),
720 "alias_uid" => array("alias(32)", "uid"),
721 "pending_uid" => array("pending", "uid"),
722 "blocked_uid" => array("blocked", "uid"),
723 "uid_rel_network_poll" => array("uid", "rel", "network", "poll(64)", "archive"),
724 "uid_network_batch" => array("uid", "network", "batch(64)"),
725 "addr_uid" => array("addr(32)", "uid"),
726 "nurl_uid" => array("nurl(32)", "uid"),
727 "nick_uid" => array("nick(32)", "uid"),
728 "dfrn-id" => array("dfrn-id"),
729 "issued-id" => array("issued-id"),
732 $database["conv"] = array(
734 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
735 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
736 "recips" => array("type" => "text"),
737 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
738 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
740 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
741 "subject" => array("type" => "text"),
744 "PRIMARY" => array("id"),
745 "uid" => array("uid"),
748 $database["event"] = array(
750 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
751 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
753 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
754 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
756 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
757 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
758 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
759 "summary" => array("type" => "text"),
760 "desc" => array("type" => "text"),
761 "location" => array("type" => "text"),
762 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
763 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
764 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
765 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
766 "allow_cid" => array("type" => "mediumtext"),
767 "allow_gid" => array("type" => "mediumtext"),
768 "deny_cid" => array("type" => "mediumtext"),
769 "deny_gid" => array("type" => "mediumtext"),
772 "PRIMARY" => array("id"),
773 "uid_start" => array("uid", "start"),
776 $database["fcontact"] = array(
778 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
779 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
780 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
781 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
782 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
783 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
784 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
785 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
786 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
787 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
788 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
789 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
790 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
792 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
793 "pubkey" => array("type" => "text"),
794 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
797 "PRIMARY" => array("id"),
798 "addr" => array("addr(32)"),
799 "url" => array("url"),
802 $database["ffinder"] = array(
804 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
805 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
806 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
807 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
810 "PRIMARY" => array("id"),
813 $database["fserver"] = array(
815 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
816 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
817 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
818 "key" => array("type" => "text"),
821 "PRIMARY" => array("id"),
822 "server" => array("server(32)"),
825 $database["fsuggest"] = array(
827 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
828 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
829 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
830 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
831 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
832 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
833 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
834 "note" => array("type" => "text"),
835 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
838 "PRIMARY" => array("id"),
841 $database["gcign"] = array(
843 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
844 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
845 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
848 "PRIMARY" => array("id"),
849 "uid" => array("uid"),
850 "gcid" => array("gcid"),
853 $database["gcontact"] = array(
855 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
856 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
857 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
858 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
859 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
860 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
861 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
862 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
863 "updated" => array("type" => "datetime", "default" => NULL_DATE),
864 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
865 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
866 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
867 "about" => array("type" => "text"),
868 "keywords" => array("type" => "text"),
869 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
870 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
871 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
872 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
873 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
874 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
875 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
876 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
877 "notify" => array("type" => "text"),
878 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
879 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
880 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
883 "PRIMARY" => array("id"),
884 "nurl" => array("nurl(64)"),
885 "name" => array("name(64)"),
886 "nick" => array("nick(32)"),
887 "addr" => array("addr(64)"),
888 "hide_network_updated" => array("hide", "network", "updated"),
889 "updated" => array("updated"),
892 $database["glink"] = array(
894 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
895 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
896 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
897 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
898 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
899 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
902 "PRIMARY" => array("id"),
903 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
904 "gcid" => array("gcid"),
907 $database["group"] = array(
909 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
910 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
911 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
912 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
913 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
916 "PRIMARY" => array("id"),
917 "uid" => array("uid"),
920 $database["group_member"] = array(
922 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
923 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
924 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
925 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
928 "PRIMARY" => array("id"),
929 "contactid" => array("contact-id"),
930 "gid_contactid" => array("gid", "contact-id"),
931 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
934 $database["gserver"] = array(
936 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
937 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
938 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
939 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
940 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
941 "info" => array("type" => "text"),
942 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
943 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
944 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
945 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
946 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
947 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
948 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
949 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
950 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
953 "PRIMARY" => array("id"),
954 "nurl" => array("nurl(32)"),
957 $database["hook"] = array(
959 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
960 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
963 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
966 "PRIMARY" => array("id"),
967 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
970 $database["intro"] = array(
972 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
973 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
974 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
975 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
976 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
977 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
978 "note" => array("type" => "text"),
979 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
980 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
981 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
982 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
985 "PRIMARY" => array("id"),
988 $database["item"] = array(
990 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
991 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
992 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
993 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
994 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
995 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
996 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
997 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
998 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
999 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1000 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1001 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1002 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1003 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1004 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1005 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1006 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1007 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1008 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1009 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1010 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1011 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1012 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1013 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1014 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1015 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1016 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1017 "body" => array("type" => "mediumtext"),
1018 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1019 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1020 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1021 "object" => array("type" => "text"),
1022 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "target" => array("type" => "text"),
1024 "postopts" => array("type" => "text"),
1025 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1026 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1027 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1028 "tag" => array("type" => "mediumtext"),
1029 "attach" => array("type" => "mediumtext"),
1030 "inform" => array("type" => "mediumtext"),
1031 "file" => array("type" => "mediumtext"),
1032 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1033 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1034 "allow_cid" => array("type" => "mediumtext"),
1035 "allow_gid" => array("type" => "mediumtext"),
1036 "deny_cid" => array("type" => "mediumtext"),
1037 "deny_gid" => array("type" => "mediumtext"),
1038 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1039 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1040 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1041 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1042 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1043 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1044 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1045 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1046 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1047 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1048 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1049 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1050 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1051 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1052 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1053 "rendered-html" => array("type" => "mediumtext"),
1054 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1057 "PRIMARY" => array("id"),
1058 "guid" => array("guid"),
1059 "uri" => array("uri"),
1060 "parent" => array("parent"),
1061 "parent-uri" => array("parent-uri"),
1062 "extid" => array("extid"),
1063 "uid_id" => array("uid","id"),
1064 "uid_contactid_id" => array("uid","contact-id","id"),
1065 "uid_created" => array("uid","created"),
1066 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1067 "uid_network_received" => array("uid","network","received"),
1068 "uid_network_commented" => array("uid","network","commented"),
1069 "uid_thrparent" => array("uid","thr-parent"),
1070 "uid_parenturi" => array("uid","parent-uri"),
1071 "uid_contactid_created" => array("uid","contact-id","created"),
1072 "authorid_created" => array("author-id","created"),
1073 "uid_uri" => array("uid", "uri"),
1074 "resource-id" => array("resource-id"),
1075 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1076 "uid_type_changed" => array("uid","type","changed"),
1077 "contactid_verb" => array("contact-id","verb"),
1078 "deleted_changed" => array("deleted","changed"),
1079 "uid_wall_changed" => array("uid","wall","changed"),
1080 "uid_eventid" => array("uid","event-id"),
1081 "uid_authorlink" => array("uid","author-link"),
1082 "uid_ownerlink" => array("uid","owner-link"),
1085 $database["item_id"] = array(
1087 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1088 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1089 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1090 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1091 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "PRIMARY" => array("id"),
1095 "uid" => array("uid"),
1096 "sid" => array("sid"),
1097 "service" => array("service(32)"),
1098 "iid" => array("iid"),
1101 $database["locks"] = array(
1103 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1104 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1105 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1106 "created" => array("type" => "datetime", "default" => NULL_DATE),
1109 "PRIMARY" => array("id"),
1112 $database["mail"] = array(
1114 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1115 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1116 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1117 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1118 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1119 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1120 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1121 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1122 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123 "body" => array("type" => "mediumtext"),
1124 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1125 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1126 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1127 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1128 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1129 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1130 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1133 "PRIMARY" => array("id"),
1134 "uid_seen" => array("uid", "seen"),
1135 "convid" => array("convid"),
1136 "uri" => array("uri(64)"),
1137 "parent-uri" => array("parent-uri(64)"),
1140 $database["mailacct"] = array(
1142 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1143 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1144 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1145 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1146 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1147 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1148 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1149 "pass" => array("type" => "text"),
1150 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1151 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1152 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1153 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1154 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1157 "PRIMARY" => array("id"),
1160 $database["manage"] = array(
1162 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1163 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1164 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1167 "PRIMARY" => array("id"),
1168 "uid_mid" => array("UNIQUE", "uid","mid"),
1171 $database["notify"] = array(
1173 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1174 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1175 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1176 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1177 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1178 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1179 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1180 "msg" => array("type" => "mediumtext"),
1181 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1182 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1183 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1184 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1185 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1186 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1187 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1188 "name_cache" => array("type" => "tinytext"),
1189 "msg_cache" => array("type" => "mediumtext")
1192 "PRIMARY" => array("id"),
1193 "hash_uid" => array("hash", "uid"),
1194 "seen_uid_date" => array("seen", "uid", "date"),
1195 "uid_date" => array("uid", "date"),
1196 "uid_type_link" => array("uid", "type", "link"),
1199 $database["notify-threads"] = array(
1201 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1202 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1203 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1204 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1205 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1208 "PRIMARY" => array("id"),
1211 $database["oembed"] = array(
1213 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1214 "content" => array("type" => "mediumtext"),
1215 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1218 "PRIMARY" => array("url"),
1219 "created" => array("created"),
1222 $database["parsed_url"] = array(
1224 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1225 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1226 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1227 "content" => array("type" => "mediumtext"),
1228 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1231 "PRIMARY" => array("url", "guessing", "oembed"),
1232 "created" => array("created"),
1235 $database["pconfig"] = array(
1237 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1238 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1239 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1240 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1241 "v" => array("type" => "mediumtext"),
1244 "PRIMARY" => array("id"),
1245 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1248 $database["photo"] = array(
1250 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1251 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1252 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1253 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1254 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1255 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1256 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1257 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1258 "desc" => array("type" => "text"),
1259 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1260 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1261 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1262 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1263 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1264 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1265 "data" => array("type" => "mediumblob", "not null" => "1"),
1266 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1267 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1268 "allow_cid" => array("type" => "mediumtext"),
1269 "allow_gid" => array("type" => "mediumtext"),
1270 "deny_cid" => array("type" => "mediumtext"),
1271 "deny_gid" => array("type" => "mediumtext"),
1274 "PRIMARY" => array("id"),
1275 "uid_contactid" => array("uid", "contact-id"),
1276 "uid_profile" => array("uid", "profile"),
1277 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1278 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1279 "resource-id" => array("resource-id(64)"),
1282 $database["poll"] = array(
1284 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1285 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1286 "q0" => array("type" => "text"),
1287 "q1" => array("type" => "text"),
1288 "q2" => array("type" => "text"),
1289 "q3" => array("type" => "text"),
1290 "q4" => array("type" => "text"),
1291 "q5" => array("type" => "text"),
1292 "q6" => array("type" => "text"),
1293 "q7" => array("type" => "text"),
1294 "q8" => array("type" => "text"),
1295 "q9" => array("type" => "text"),
1298 "PRIMARY" => array("id"),
1299 "uid" => array("uid"),
1302 $database["poll_result"] = array(
1304 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1305 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1306 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1309 "PRIMARY" => array("id"),
1310 "poll_id" => array("poll_id"),
1311 "choice" => array("choice"),
1314 $database["process"] = array(
1316 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1317 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1318 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1321 "PRIMARY" => array("pid"),
1322 "command" => array("command"),
1325 $database["profile"] = array(
1327 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1328 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1329 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1330 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1331 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1332 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1333 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1334 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1335 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1336 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1337 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1338 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1339 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1340 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1341 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1342 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1343 "with" => array("type" => "text"),
1344 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1345 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1346 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1347 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1348 "pub_keywords" => array("type" => "text"),
1349 "prv_keywords" => array("type" => "text"),
1350 "likes" => array("type" => "text"),
1351 "dislikes" => array("type" => "text"),
1352 "about" => array("type" => "text"),
1353 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1354 "music" => array("type" => "text"),
1355 "book" => array("type" => "text"),
1356 "tv" => array("type" => "text"),
1357 "film" => array("type" => "text"),
1358 "interest" => array("type" => "text"),
1359 "romance" => array("type" => "text"),
1360 "work" => array("type" => "text"),
1361 "education" => array("type" => "text"),
1362 "contact" => array("type" => "text"),
1363 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1364 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1365 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1366 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1367 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1368 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1371 "PRIMARY" => array("id"),
1372 "uid_is-default" => array("uid", "is-default"),
1375 $database["profile_check"] = array(
1377 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1378 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1379 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1380 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1381 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1382 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1385 "PRIMARY" => array("id"),
1388 $database["push_subscriber"] = array(
1390 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1391 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1392 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1393 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1394 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1395 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1396 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1397 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1400 "PRIMARY" => array("id"),
1403 $database["queue"] = array(
1405 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1406 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1407 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1408 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1409 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1410 "content" => array("type" => "mediumtext"),
1411 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1414 "PRIMARY" => array("id"),
1415 "cid" => array("cid"),
1416 "created" => array("created"),
1417 "last" => array("last"),
1418 "network" => array("network"),
1419 "batch" => array("batch"),
1422 $database["register"] = array(
1424 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1425 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1426 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1427 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1428 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1429 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1430 "note" => array("type" => "text"),
1433 "PRIMARY" => array("id"),
1436 $database["search"] = array(
1438 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1439 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1440 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1443 "PRIMARY" => array("id"),
1444 "uid" => array("uid"),
1447 $database["session"] = array(
1449 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1450 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1451 "data" => array("type" => "text"),
1452 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1455 "PRIMARY" => array("id"),
1456 "sid" => array("sid(64)"),
1457 "expire" => array("expire"),
1460 $database["sign"] = array(
1462 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1463 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1464 "signed_text" => array("type" => "mediumtext"),
1465 "signature" => array("type" => "text"),
1466 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1469 "PRIMARY" => array("id"),
1470 "iid" => array("iid"),
1473 $database["spam"] = array(
1475 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1476 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1477 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1478 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1479 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1480 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1483 "PRIMARY" => array("id"),
1484 "uid" => array("uid"),
1485 "spam" => array("spam"),
1486 "ham" => array("ham"),
1487 "term" => array("term"),
1490 $database["term"] = array(
1492 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1493 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1494 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1495 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1496 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1497 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1498 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1499 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1500 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1501 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1502 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1503 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1506 "PRIMARY" => array("tid"),
1507 "oid_otype_type_term" => array("oid","otype","type","term"),
1508 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1509 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1510 "guid" => array("guid(64)"),
1513 $database["thread"] = array(
1515 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1516 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1517 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1518 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1519 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1520 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1521 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1522 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1523 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1524 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1525 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1526 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1527 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1528 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1529 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1530 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1531 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1532 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1533 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1534 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1535 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1536 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1537 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1538 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1539 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1540 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1543 "PRIMARY" => array("iid"),
1544 "uid_network_commented" => array("uid","network","commented"),
1545 "uid_network_created" => array("uid","network","created"),
1546 "uid_contactid_commented" => array("uid","contact-id","commented"),
1547 "uid_contactid_created" => array("uid","contact-id","created"),
1548 "uid_created" => array("uid","created"),
1549 "uid_commented" => array("uid","commented"),
1550 "uid_wall_created" => array("uid","wall","created"),
1553 $database["tokens"] = array(
1555 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1556 "secret" => array("type" => "text"),
1557 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1558 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1559 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1560 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1563 "PRIMARY" => array("id"),
1566 $database["user"] = array(
1568 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1569 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1570 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1571 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1572 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1573 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1574 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1575 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1576 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1577 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1578 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1579 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1580 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1581 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1582 "pubkey" => array("type" => "text"),
1583 "prvkey" => array("type" => "text"),
1584 "spubkey" => array("type" => "text"),
1585 "sprvkey" => array("type" => "text"),
1586 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1587 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1588 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1589 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1590 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1591 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1592 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1593 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1594 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1595 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1596 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1597 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1598 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1599 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1600 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1601 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1602 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1603 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1604 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1605 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1606 "allow_cid" => array("type" => "mediumtext"),
1607 "allow_gid" => array("type" => "mediumtext"),
1608 "deny_cid" => array("type" => "mediumtext"),
1609 "deny_gid" => array("type" => "mediumtext"),
1610 "openidserver" => array("type" => "text"),
1613 "PRIMARY" => array("uid"),
1614 "nickname" => array("nickname(32)"),
1617 $database["userd"] = array(
1619 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1620 "username" => array("type" => "varchar(255)", "not null" => "1"),
1623 "PRIMARY" => array("id"),
1624 "username" => array("username(32)"),
1627 $database["workerqueue"] = array(
1629 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1630 "parameter" => array("type" => "text"),
1631 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1632 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1633 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1634 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1637 "PRIMARY" => array("id"),
1646 * run from command line
1648 function dbstructure_run(&$argv, &$argc) {
1656 @include(".htconfig.php");
1657 require_once("include/dba.php");
1658 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1659 unset($db_host, $db_user, $db_pass, $db_data);
1665 update_structure(true, false);
1668 update_structure(true, true);
1670 $build = get_config('system','build');
1672 set_config('system','build',DB_UPDATE_VERSION);
1673 $build = DB_UPDATE_VERSION;
1676 $stored = intval($build);
1677 $current = intval(DB_UPDATE_VERSION);
1679 // run any left update_nnnn functions in update.php
1680 for($x = $stored; $x < $current; $x ++) {
1681 $r = run_update_function($x);
1685 set_config('system','build',DB_UPDATE_VERSION);
1688 print_structure(db_definition());
1695 echo $argv[0]." <command>\n";
1698 echo "dryrun show database update schema queries without running them\n";
1699 echo "update update database schema\n";
1700 echo "dumpsql dump database schema\n";
1705 if (array_search(__file__,get_included_files())===0){
1706 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);