Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1668 lines
77 KiB

  1. <?php
  2. require_once("boot.php");
  3. require_once("include/text.php");
  4. define('NEW_UPDATE_ROUTINE_VERSION', 1170);
  5. /*
  6. * send the email and do what is needed to do on update fails
  7. *
  8. * @param update_id (int) number of failed update
  9. * @param error_message (str) error message
  10. */
  11. function update_fail($update_id, $error_message){
  12. //send the administrators an e-mail
  13. $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
  14. $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
  15. $admin_mail_list
  16. );
  17. // No valid result?
  18. if (!dbm::is_result($adminlist)) {
  19. logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
  20. // Don't continue
  21. return;
  22. }
  23. // every admin could had different language
  24. foreach ($adminlist as $admin) {
  25. $lang = (($admin['language'])?$admin['language']:'en');
  26. push_lang($lang);
  27. $preamble = deindent(t("
  28. The friendica developers released update %s recently,
  29. but when I tried to install it, something went terribly wrong.
  30. This needs to be fixed soon and I can't do it alone. Please contact a
  31. friendica developer if you can not help me on your own. My database might be invalid."));
  32. $body = t("The error message is\n[pre]%s[/pre]");
  33. $preamble = sprintf($preamble, $update_id);
  34. $body = sprintf($body, $error_message);
  35. notification(array(
  36. 'type' => "SYSTEM_EMAIL",
  37. 'to_email' => $admin['email'],
  38. 'preamble' => $preamble,
  39. 'body' => $body,
  40. 'language' => $lang,
  41. ));
  42. }
  43. /*
  44. $email_tpl = get_intltext_template("update_fail_eml.tpl");
  45. $email_msg = replace_macros($email_tpl, array(
  46. '$sitename' => $a->config['sitename'],
  47. '$siteurl' => App::get_baseurl(),
  48. '$update' => DB_UPDATE_VERSION,
  49. '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
  50. ));
  51. $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
  52. require_once('include/email.php');
  53. $subject = email_header_encode($subject,'UTF-8');
  54. mail($a->config['admin_email'], $subject, $email_msg,
  55. 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
  56. .'Content-type: text/plain; charset=UTF-8'."\n"
  57. .'Content-transfer-encoding: 8bit');
  58. */
  59. //try the logger
  60. logger("CRITICAL: Database structure update failed: ".$retval);
  61. }
  62. function table_structure($table) {
  63. $structures = q("DESCRIBE `%s`", $table);
  64. $indexes = q("SHOW INDEX FROM `%s`", $table);
  65. $fielddata = array();
  66. $indexdata = array();
  67. if (dbm::is_result($indexes))
  68. foreach ($indexes AS $index) {
  69. if ($index["Index_type"] == "FULLTEXT") {
  70. continue;
  71. }
  72. if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
  73. $indexdata[$index["Key_name"]] = array('UNIQUE');
  74. }
  75. $column = $index["Column_name"];
  76. // On utf8mb4 a varchar index can only have a length of 191
  77. // To avoid the need to add this to every index definition we just ignore it here.
  78. // Exception are primary indexes
  79. // Since there are some combindex primary indexes we use the limit of 180 here.
  80. if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) {
  81. $column .= "(".$index["Sub_part"].")";
  82. }
  83. $indexdata[$index["Key_name"]][] = $column;
  84. }
  85. if (dbm::is_result($structures)) {
  86. foreach ($structures AS $field) {
  87. $fielddata[$field["Field"]]["type"] = $field["Type"];
  88. if ($field["Null"] == "NO") {
  89. $fielddata[$field["Field"]]["not null"] = true;
  90. }
  91. if (isset($field["Default"])) {
  92. $fielddata[$field["Field"]]["default"] = $field["Default"];
  93. }
  94. if ($field["Extra"] != "") {
  95. $fielddata[$field["Field"]]["extra"] = $field["Extra"];
  96. }
  97. if ($field["Key"] == "PRI") {
  98. $fielddata[$field["Field"]]["primary"] = true;
  99. }
  100. }
  101. }
  102. return(array("fields"=>$fielddata, "indexes"=>$indexdata));
  103. }
  104. function print_structure($database, $charset) {
  105. echo "-- ------------------------------------------\n";
  106. echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
  107. echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
  108. echo "-- ------------------------------------------\n\n\n";
  109. foreach ($database AS $name => $structure) {
  110. echo "--\n";
  111. echo "-- TABLE $name\n";
  112. echo "--\n";
  113. db_create_table($name, $structure['fields'], $charset, true, false, $structure["indexes"]);
  114. echo "\n";
  115. }
  116. }
  117. function update_structure($verbose, $action, $tables=null, $definition=null) {
  118. global $a, $db;
  119. if ($action) {
  120. set_config('system', 'maintenance', 1);
  121. }
  122. if (isset($a->config["system"]["db_charset"])) {
  123. $charset = $a->config["system"]["db_charset"];
  124. } else {
  125. $charset = "utf8";
  126. }
  127. $errors = false;
  128. logger('updating structure', LOGGER_DEBUG);
  129. // Get the current structure
  130. $database = array();
  131. if (is_null($tables)) {
  132. $tables = q("SHOW TABLES");
  133. }
  134. foreach ($tables AS $table) {
  135. $table = current($table);
  136. logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
  137. $database[$table] = table_structure($table);
  138. }
  139. // Get the definition
  140. if (is_null($definition)) {
  141. $definition = db_definition($charset);
  142. }
  143. // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
  144. if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
  145. !(strpos($db->server_info(), 'MariaDB') !== false)) {
  146. $ignore = '';
  147. } else {
  148. $ignore = ' IGNORE';
  149. }
  150. // Compare it
  151. foreach ($definition AS $name => $structure) {
  152. $is_new_table = False;
  153. $sql3="";
  154. if (!isset($database[$name])) {
  155. $r = db_create_table($name, $structure["fields"], $charset, $verbose, $action, $structure['indexes']);
  156. if (!dbm::is_result($r)) {
  157. $errors .= t('Errors encountered creating database tables.').$name.EOL;
  158. }
  159. $is_new_table = True;
  160. } else {
  161. $is_unique = false;
  162. $temp_name = $name;
  163. foreach ($structure["indexes"] AS $indexname => $fieldnames) {
  164. if (isset($database[$name]["indexes"][$indexname])) {
  165. $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
  166. } else {
  167. $current_index_definition = "__NOT_SET__";
  168. }
  169. $new_index_definition = implode(",",$fieldnames);
  170. if ($current_index_definition != $new_index_definition) {
  171. if ($fieldnames[0] == "UNIQUE") {
  172. $is_unique = true;
  173. // Deactivated. See below for the reason
  174. //if ($ignore == "") {
  175. // $temp_name = "temp-".$name;
  176. //}
  177. }
  178. }
  179. }
  180. /*
  181. * Drop the index if it isn't present in the definition
  182. * or the definition differ from current status
  183. * and index name doesn't start with "local_"
  184. */
  185. foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
  186. $current_index_definition = implode(",",$fieldnames);
  187. if (isset($structure["indexes"][$indexname])) {
  188. $new_index_definition = implode(",",$structure["indexes"][$indexname]);
  189. } else {
  190. $new_index_definition = "__NOT_SET__";
  191. }
  192. if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
  193. $sql2=db_drop_index($indexname);
  194. if ($sql3 == "") {
  195. $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
  196. } else {
  197. $sql3 .= ", ".$sql2;
  198. }
  199. }
  200. }
  201. // Compare the field structure field by field
  202. foreach ($structure["fields"] AS $fieldname => $parameters) {
  203. if (!isset($database[$name]["fields"][$fieldname])) {
  204. $sql2=db_add_table_field($fieldname, $parameters);
  205. if ($sql3 == "") {
  206. $sql3 = "ALTER TABLE `".$temp_name."` ".$sql2;
  207. } else {
  208. $sql3 .= ", ".$sql2;
  209. }
  210. } else {
  211. // Compare the field definition
  212. $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
  213. $new_field_definition = implode(",",$parameters);
  214. if ($current_field_definition != $new_field_definition) {
  215. $sql2=db_modify_table_field($fieldname, $parameters);
  216. if ($sql3 == "") {
  217. $sql3 = "ALTER TABLE `".$temp_name."` ".$sql2;
  218. } else {
  219. $sql3 .= ", ".$sql2;
  220. }
  221. }
  222. }
  223. }
  224. }
  225. /*
  226. * Create the index if the index don't exists in database
  227. * or the definition differ from the current status.
  228. * Don't create keys if table is new
  229. */
  230. if (!$is_new_table) {
  231. foreach ($structure["indexes"] AS $indexname => $fieldnames) {
  232. if (isset($database[$name]["indexes"][$indexname])) {
  233. $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
  234. } else {
  235. $current_index_definition = "__NOT_SET__";
  236. }
  237. $new_index_definition = implode(",",$fieldnames);
  238. if ($current_index_definition != $new_index_definition) {
  239. $sql2=db_create_index($indexname, $fieldnames);
  240. if ($sql2 != "") {
  241. if ($sql3 == "")
  242. $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
  243. else
  244. $sql3 .= ", ".$sql2;
  245. }
  246. }
  247. }
  248. }
  249. if ($sql3 != "") {
  250. $sql3 .= ";";
  251. if ($verbose) {
  252. // Ensure index conversion to unique removes duplicates
  253. if ($is_unique) {
  254. // By now the alternative is commented out.
  255. // This is a preparation for the time when we found a good SQL routine.
  256. //if ($ignore != "") {
  257. echo "SET session old_alter_table=1;\n";
  258. //} else {
  259. // echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
  260. //}
  261. }
  262. echo $sql3."\n";
  263. if ($is_unique) {
  264. // By now the alternative is commented out.
  265. // This is a preparation for the time when we found a good SQL routine.
  266. //if ($ignore != "") {
  267. echo "SET session old_alter_table=0;\n";
  268. //} else {
  269. // echo "INSERT IGNORE INTO `".$temp_name."` SELECT * FROM `".$name."`;\n";
  270. // echo "DROP TABLE `".$name."`;\n";
  271. // echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
  272. //}
  273. }
  274. }
  275. if ($action) {
  276. // Ensure index conversion to unique removes duplicates
  277. if ($is_unique) {
  278. // By now the alternative is commented out.
  279. // This is a preparation for the time when we found a good SQL routine.
  280. //if ($ignore != "") {
  281. $db->q("SET session old_alter_table=1;");
  282. //} else {
  283. // $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
  284. // if (!dbm::is_result($r)) {
  285. // $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
  286. // return $errors;
  287. // }
  288. //}
  289. }
  290. $r = @$db->q($sql3);
  291. if (!dbm::is_result($r))
  292. $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
  293. if ($is_unique) {
  294. // By now the alternative is commented out.
  295. // This is a preparation for the time when we found a good SQL routine.
  296. //if ($ignore != "") {
  297. $db->q("SET session old_alter_table=0;");
  298. //} else {
  299. // We have to check if "INSERT IGNORE" will work on newer MySQL versions
  300. // $r = $db->q("INSERT IGNORE INTO `".$temp_name."` SELECT * FROM `".$name."`;");
  301. // if (!dbm::is_result($r)) {
  302. // $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
  303. // return $errors;
  304. // }
  305. // $r = $db->q("DROP TABLE `".$name."`;");
  306. // if (!dbm::is_result($r)) {
  307. // $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
  308. // return $errors;
  309. // }
  310. // $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
  311. // if (!dbm::is_result($r)) {
  312. // $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
  313. // return $errors;
  314. // }
  315. //}
  316. }
  317. }
  318. }
  319. }
  320. if ($action)
  321. set_config('system', 'maintenance', 0);
  322. return $errors;
  323. }
  324. function db_field_command($parameters, $create = true) {
  325. $fieldstruct = $parameters["type"];
  326. if ($parameters["not null"])
  327. $fieldstruct .= " NOT NULL";
  328. if (isset($parameters["default"])){
  329. if (strpos(strtolower($parameters["type"]),"int")!==false) {
  330. $fieldstruct .= " DEFAULT ".$parameters["default"];
  331. } else {
  332. $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
  333. }
  334. }
  335. if ($parameters["extra"] != "")
  336. $fieldstruct .= " ".$parameters["extra"];
  337. /*if (($parameters["primary"] != "") AND $create)
  338. $fieldstruct .= " PRIMARY KEY";*/
  339. return($fieldstruct);
  340. }
  341. function db_create_table($name, $fields, $charset, $verbose, $action, $indexes=null) {
  342. global $a, $db;
  343. $r = true;
  344. $sql = "";
  345. $sql_rows = array();
  346. $primary_keys = array();
  347. foreach($fields AS $fieldname => $field) {
  348. $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
  349. if (x($field,'primary') and $field['primary']!=''){
  350. $primary_keys[] = $fieldname;
  351. }
  352. }
  353. if (!is_null($indexes)) {
  354. foreach ($indexes AS $indexname => $fieldnames) {
  355. $sql_index = db_create_index($indexname, $fieldnames, "");
  356. if (!is_null($sql_index)) $sql_rows[] = $sql_index;
  357. }
  358. }
  359. $sql = implode(",\n\t", $sql_rows);
  360. $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=".$charset;
  361. if ($verbose)
  362. echo $sql.";\n";
  363. if ($action)
  364. $r = @$db->q($sql);
  365. return $r;
  366. }
  367. function db_add_table_field($fieldname, $parameters) {
  368. $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
  369. return($sql);
  370. }
  371. function db_modify_table_field($fieldname, $parameters) {
  372. $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
  373. return($sql);
  374. }
  375. function db_drop_index($indexname) {
  376. $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
  377. return($sql);
  378. }
  379. function db_create_index($indexname, $fieldnames, $method="ADD") {
  380. $method = strtoupper(trim($method));
  381. if ($method!="" && $method!="ADD") {
  382. throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
  383. killme();
  384. }
  385. if ($fieldnames[0] == "UNIQUE") {
  386. array_shift($fieldnames);
  387. $method .= ' UNIQUE';
  388. }
  389. $names = "";
  390. foreach ($fieldnames AS $fieldname) {
  391. if ($names != "")
  392. $names .= ",";
  393. if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
  394. $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
  395. } else {
  396. $names .= "`".dbesc($fieldname)."`";
  397. }
  398. }
  399. if ($indexname == "PRIMARY") {
  400. return sprintf("%s PRIMARY KEY(%s)", $method, $names);
  401. }
  402. $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
  403. return($sql);
  404. }
  405. function db_index_suffix($charset, $reduce = 0) {
  406. if ($charset != "utf8mb4") {
  407. return "";
  408. }
  409. // On utf8mb4 indexes can only have a length of 191
  410. $indexlength = 191 - $reduce;
  411. return "(".$indexlength.")";
  412. }
  413. function db_definition($charset) {
  414. $database = array();
  415. $database["addon"] = array(
  416. "fields" => array(
  417. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  418. "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
  419. "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  420. "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  421. "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  422. "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
  423. "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  424. ),
  425. "indexes" => array(
  426. "PRIMARY" => array("id"),
  427. "name" => array("UNIQUE", "name"),
  428. )
  429. );
  430. $database["attach"] = array(
  431. "fields" => array(
  432. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  433. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  434. "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  435. "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  436. "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  437. "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  438. "data" => array("type" => "longblob", "not null" => "1"),
  439. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  440. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  441. "allow_cid" => array("type" => "mediumtext"),
  442. "allow_gid" => array("type" => "mediumtext"),
  443. "deny_cid" => array("type" => "mediumtext"),
  444. "deny_gid" => array("type" => "mediumtext"),
  445. ),
  446. "indexes" => array(
  447. "PRIMARY" => array("id"),
  448. )
  449. );
  450. $database["auth_codes"] = array(
  451. "fields" => array(
  452. "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
  453. "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
  454. "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
  455. "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  456. "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
  457. ),
  458. "indexes" => array(
  459. "PRIMARY" => array("id"),
  460. )
  461. );
  462. $database["cache"] = array(
  463. "fields" => array(
  464. "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
  465. "v" => array("type" => "mediumtext"),
  466. "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  467. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  468. ),
  469. "indexes" => array(
  470. "PRIMARY" => array("k"),
  471. "expire_mode_updated" => array("expire_mode", "updated"),
  472. )
  473. );
  474. $database["challenge"] = array(
  475. "fields" => array(
  476. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  477. "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  478. "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  479. "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  480. "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  481. "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  482. ),
  483. "indexes" => array(
  484. "PRIMARY" => array("id"),
  485. )
  486. );
  487. $database["clients"] = array(
  488. "fields" => array(
  489. "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
  490. "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
  491. "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
  492. "name" => array("type" => "text"),
  493. "icon" => array("type" => "text"),
  494. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  495. ),
  496. "indexes" => array(
  497. "PRIMARY" => array("client_id"),
  498. )
  499. );
  500. $database["config"] = array(
  501. "fields" => array(
  502. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  503. "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  504. "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  505. "v" => array("type" => "mediumtext"),
  506. ),
  507. "indexes" => array(
  508. "PRIMARY" => array("id"),
  509. "cat_k" => array("UNIQUE", "cat", "k"),
  510. )
  511. );
  512. $database["contact"] = array(
  513. "fields" => array(
  514. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  515. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  516. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  517. "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  518. "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  519. "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  520. "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  521. "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  522. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  523. "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  524. "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  525. "about" => array("type" => "text"),
  526. "keywords" => array("type" => "text"),
  527. "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  528. "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  529. "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  530. "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  531. "photo" => array("type" => "text"),
  532. "thumb" => array("type" => "text"),
  533. "micro" => array("type" => "text"),
  534. "site-pubkey" => array("type" => "text"),
  535. "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  536. "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  537. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  538. "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  539. "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  540. "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  541. "pubkey" => array("type" => "text"),
  542. "prvkey" => array("type" => "text"),
  543. "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  544. "request" => array("type" => "text"),
  545. "notify" => array("type" => "text"),
  546. "poll" => array("type" => "text"),
  547. "confirm" => array("type" => "text"),
  548. "poco" => array("type" => "text"),
  549. "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  550. "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  551. "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  552. "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  553. "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  554. "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  555. "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  556. "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  557. "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  558. "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  559. "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  560. "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  561. "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  562. "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
  563. "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  564. "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  565. "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  566. "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  567. "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  568. "contact-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  569. "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  570. "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  571. "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  572. "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  573. "reason" => array("type" => "text"),
  574. "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
  575. "info" => array("type" => "mediumtext"),
  576. "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  577. "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
  578. "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
  579. "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  580. "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  581. "ffi_keyword_blacklist" => array("type" => "text"),
  582. ),
  583. "indexes" => array(
  584. "PRIMARY" => array("id"),
  585. "uid_name" => array("uid", "name"),
  586. "self_uid" => array("self", "uid"),
  587. "alias_uid" => array("alias(32)", "uid"),
  588. "pending_uid" => array("pending", "uid"),
  589. "blocked_uid" => array("blocked", "uid"),
  590. "uid_rel_network_poll" => array("uid", "rel", "network", "poll(64)", "archive"),
  591. "uid_network_batch" => array("uid", "network", "batch(64)"),
  592. "addr_uid" => array("addr(32)", "uid"),
  593. "nurl_uid" => array("nurl(32)", "uid"),
  594. "nick_uid" => array("nick(32)", "uid"),
  595. "dfrn-id" => array("dfrn-id"),
  596. "issued-id" => array("issued-id"),
  597. )
  598. );
  599. $database["conv"] = array(
  600. "fields" => array(
  601. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  602. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  603. "recips" => array("type" => "text"),
  604. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  605. "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  606. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  607. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  608. "subject" => array("type" => "text"),
  609. ),
  610. "indexes" => array(
  611. "PRIMARY" => array("id"),
  612. "uid" => array("uid"),
  613. )
  614. );
  615. $database["deliverq"] = array(
  616. "fields" => array(
  617. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  618. "cmd" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
  619. "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  620. "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  621. ),
  622. "indexes" => array(
  623. "PRIMARY" => array("id"),
  624. "cmd_item_contact" => array("UNIQUE", "cmd", "item", "contact"),
  625. )
  626. );
  627. $database["event"] = array(
  628. "fields" => array(
  629. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  630. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  631. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  632. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  633. "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  634. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  635. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  636. "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  637. "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  638. "summary" => array("type" => "text"),
  639. "desc" => array("type" => "text"),
  640. "location" => array("type" => "text"),
  641. "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  642. "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  643. "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  644. "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  645. "allow_cid" => array("type" => "mediumtext"),
  646. "allow_gid" => array("type" => "mediumtext"),
  647. "deny_cid" => array("type" => "mediumtext"),
  648. "deny_gid" => array("type" => "mediumtext"),
  649. ),
  650. "indexes" => array(
  651. "PRIMARY" => array("id"),
  652. "uid_start" => array("uid", "start"),
  653. )
  654. );
  655. $database["fcontact"] = array(
  656. "fields" => array(
  657. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  658. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  659. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  660. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  661. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  662. "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  663. "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  664. "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  665. "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  666. "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  667. "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  668. "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  669. "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  670. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  671. "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  672. "pubkey" => array("type" => "text"),
  673. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  674. ),
  675. "indexes" => array(
  676. "PRIMARY" => array("id"),
  677. "addr" => array("addr(32)"),
  678. "url" => array("url"),
  679. )
  680. );
  681. $database["ffinder"] = array(
  682. "fields" => array(
  683. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  684. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  685. "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  686. "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  687. ),
  688. "indexes" => array(
  689. "PRIMARY" => array("id"),
  690. )
  691. );
  692. $database["fserver"] = array(
  693. "fields" => array(
  694. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  695. "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  696. "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  697. "key" => array("type" => "text"),
  698. ),
  699. "indexes" => array(
  700. "PRIMARY" => array("id"),
  701. "server" => array("server(32)"),
  702. )
  703. );
  704. $database["fsuggest"] = array(
  705. "fields" => array(
  706. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  707. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  708. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  709. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  710. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  711. "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  712. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  713. "note" => array("type" => "text"),
  714. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  715. ),
  716. "indexes" => array(
  717. "PRIMARY" => array("id"),
  718. )
  719. );
  720. $database["gcign"] = array(
  721. "fields" => array(
  722. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  723. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  724. "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  725. ),
  726. "indexes" => array(
  727. "PRIMARY" => array("id"),
  728. "uid" => array("uid"),
  729. "gcid" => array("gcid"),
  730. )
  731. );
  732. $database["gcontact"] = array(
  733. "fields" => array(
  734. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  735. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  736. "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  737. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  738. "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  739. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  740. "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  741. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  742. "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  743. "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  744. "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  745. "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  746. "about" => array("type" => "text"),
  747. "keywords" => array("type" => "text"),
  748. "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  749. "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
  750. "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  751. "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
  752. "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  753. "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  754. "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  755. "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  756. "notify" => array("type" => "text"),
  757. "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  758. "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
  759. "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  760. ),
  761. "indexes" => array(
  762. "PRIMARY" => array("id"),
  763. "nurl" => array("nurl(32)"),
  764. "name" => array("name(32)"),
  765. "nick" => array("nick(32)"),
  766. "addr" => array("addr(32)"),
  767. "hide_network_updated" => array("hide", "network", "updated"),
  768. "updated" => array("updated"),
  769. )
  770. );
  771. $database["glink"] = array(
  772. "fields" => array(
  773. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  774. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  775. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  776. "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  777. "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  778. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  779. ),
  780. "indexes" => array(
  781. "PRIMARY" => array("id"),
  782. "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
  783. "gcid" => array("gcid"),
  784. )
  785. );
  786. $database["group"] = array(
  787. "fields" => array(
  788. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  789. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  790. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  791. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  792. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  793. ),
  794. "indexes" => array(
  795. "PRIMARY" => array("id"),
  796. "uid" => array("uid"),
  797. )
  798. );
  799. $database["group_member"] = array(
  800. "fields" => array(
  801. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  802. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  803. "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  804. "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  805. ),
  806. "indexes" => array(
  807. "PRIMARY" => array("id"),
  808. "contactid" => array("contact-id"),
  809. "gid_contactid" => array("gid", "contact-id"),
  810. "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
  811. )
  812. );
  813. $database["gserver"] = array(
  814. "fields" => array(
  815. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  816. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  817. "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  818. "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  819. "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  820. "info" => array("type" => "text"),
  821. "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  822. "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  823. "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  824. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  825. "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  826. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  827. "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  828. "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  829. "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  830. ),
  831. "indexes" => array(
  832. "PRIMARY" => array("id"),
  833. "nurl" => array("nurl(32)"),
  834. )
  835. );
  836. $database["hook"] = array(
  837. "fields" => array(
  838. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  839. "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  840. "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  841. "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  842. "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  843. ),
  844. "indexes" => array(
  845. "PRIMARY" => array("id"),
  846. "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
  847. )
  848. );
  849. $database["intro"] = array(
  850. "fields" => array(
  851. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  852. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  853. "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  854. "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  855. "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  856. "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  857. "note" => array("type" => "text"),
  858. "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  859. "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  860. "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  861. "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  862. ),
  863. "indexes" => array(
  864. "PRIMARY" => array("id"),
  865. )
  866. );
  867. $database["item"] = array(
  868. "fields" => array(
  869. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  870. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  871. "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  872. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  873. "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  874. "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  875. "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  876. "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  877. "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  878. "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  879. "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  880. "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  881. "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  882. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  883. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  884. "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  885. "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  886. "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  887. "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  888. "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  889. "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  890. "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  891. "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  892. "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  893. "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  894. "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  895. "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  896. "body" => array("type" => "mediumtext"),
  897. "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  898. "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  899. "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  900. "object" => array("type" => "text"),
  901. "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  902. "target" => array("type" => "text"),
  903. "postopts" => array("type" => "text"),
  904. "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  905. "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  906. "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  907. "tag" => array("type" => "mediumtext"),
  908. "attach" => array("type" => "mediumtext"),
  909. "inform" => array("type" => "mediumtext"),
  910. "file" => array("type" => "mediumtext"),
  911. "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  912. "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  913. "allow_cid" => array("type" => "mediumtext"),
  914. "allow_gid" => array("type" => "mediumtext"),
  915. "deny_cid" => array("type" => "mediumtext"),
  916. "deny_gid" => array("type" => "mediumtext"),
  917. "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  918. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  919. "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  920. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  921. "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  922. "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  923. "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  924. "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  925. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  926. "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  927. "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  928. "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
  929. "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  930. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  931. "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  932. "rendered-html" => array("type" => "mediumtext"),
  933. "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  934. ),
  935. "indexes" => array(
  936. "PRIMARY" => array("id"),
  937. "guid" => array("guid"),
  938. "uri" => array("uri"),
  939. "parent" => array("parent"),
  940. "parent-uri" => array("parent-uri"),
  941. "extid" => array("extid"),
  942. "uid_id" => array("uid","id"),
  943. "uid_created" => array("uid","created"),
  944. "uid_unseen_contactid" => array("uid","unseen","contact-id"),
  945. "uid_network_received" => array("uid","network","received"),
  946. "uid_network_commented" => array("uid","network","commented"),
  947. "uid_thrparent" => array("uid","thr-parent"),
  948. "uid_parenturi" => array("uid","parent-uri"),
  949. "uid_contactid_created" => array("uid","contact-id","created"),
  950. "authorid_created" => array("author-id","created"),
  951. "uid_uri" => array("uid", "uri"),
  952. "resource-id" => array("resource-id"),
  953. "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
  954. "uid_type_changed" => array("uid","type","changed"),
  955. "contactid_verb" => array("contact-id","verb"),
  956. "deleted_changed" => array("deleted","changed"),
  957. "uid_wall_changed" => array("uid","wall","changed"),
  958. "uid_eventid" => array("uid","event-id"),
  959. "uid_authorlink" => array("uid","author-link"),
  960. "uid_ownerlink" => array("uid","owner-link"),
  961. )
  962. );
  963. $database["item_id"] = array(
  964. "fields" => array(
  965. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  966. "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  967. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  968. "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  969. "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  970. ),
  971. "indexes" => array(
  972. "PRIMARY" => array("id"),
  973. "uid" => array("uid"),
  974. "sid" => array("sid"),
  975. "service" => array("service(32)"),
  976. "iid" => array("iid"),
  977. )
  978. );
  979. $database["locks"] = array(
  980. "fields" => array(
  981. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  982. "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
  983. "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  984. "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  985. ),
  986. "indexes" => array(
  987. "PRIMARY" => array("id"),
  988. )
  989. );
  990. $database["mail"] = array(
  991. "fields" => array(
  992. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  993. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  994. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  995. "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  996. "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  997. "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  998. "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  999. "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1000. "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1001. "body" => array("type" => "mediumtext"),
  1002. "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1003. "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1004. "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1005. "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1006. "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1007. "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1008. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1009. ),
  1010. "indexes" => array(
  1011. "PRIMARY" => array("id"),
  1012. "uid_seen" => array("uid", "seen"),
  1013. "convid" => array("convid"),
  1014. "uri" => array("uri(64)"),
  1015. "parent-uri" => array("parent-uri(64)"),
  1016. )
  1017. );
  1018. $database["mailacct"] = array(
  1019. "fields" => array(
  1020. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1021. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1022. "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1023. "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1024. "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
  1025. "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1026. "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1027. "pass" => array("type" => "text"),
  1028. "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1029. "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1030. "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1031. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1032. "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1033. ),
  1034. "indexes" => array(
  1035. "PRIMARY" => array("id"),
  1036. )
  1037. );
  1038. $database["manage"] = array(
  1039. "fields" => array(
  1040. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1041. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1042. "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1043. ),
  1044. "indexes" => array(
  1045. "PRIMARY" => array("id"),
  1046. "uid_mid" => array("UNIQUE", "uid","mid"),
  1047. )
  1048. );
  1049. $database["notify"] = array(
  1050. "fields" => array(
  1051. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1052. "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  1053. "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1054. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1055. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1056. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1057. "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1058. "msg" => array("type" => "mediumtext"),
  1059. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1060. "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1061. "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1062. "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1063. "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1064. "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1065. "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
  1066. "name_cache" => array("type" => "tinytext"),
  1067. "msg_cache" => array("type" => "mediumtext")
  1068. ),
  1069. "indexes" => array(
  1070. "PRIMARY" => array("id"),
  1071. "hash_uid" => array("hash", "uid"),
  1072. "seen_uid_date" => array("seen", "uid", "date"),
  1073. "uid_date" => array("uid", "date"),
  1074. "uid_type_link" => array("uid", "type", "link"),
  1075. )
  1076. );
  1077. $database["notify-threads"] = array(
  1078. "fields" => array(
  1079. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1080. "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1081. "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1082. "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1083. "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1084. ),
  1085. "indexes" => array(
  1086. "PRIMARY" => array("id"),
  1087. )
  1088. );
  1089. $database["oembed"] = array(
  1090. "fields" => array(
  1091. "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
  1092. "content" => array("type" => "mediumtext"),
  1093. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1094. ),
  1095. "indexes" => array(
  1096. "PRIMARY" => array("url"),
  1097. "created" => array("created"),
  1098. )
  1099. );
  1100. $database["parsed_url"] = array(
  1101. "fields" => array(
  1102. "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
  1103. "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
  1104. "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
  1105. "content" => array("type" => "mediumtext"),
  1106. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1107. ),
  1108. "indexes" => array(
  1109. "PRIMARY" => array("url", "guessing", "oembed"),
  1110. "created" => array("created"),
  1111. )
  1112. );
  1113. $database["pconfig"] = array(
  1114. "fields" => array(
  1115. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1116. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1117. "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  1118. "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  1119. "v" => array("type" => "mediumtext"),
  1120. ),
  1121. "indexes" => array(
  1122. "PRIMARY" => array("id"),
  1123. "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
  1124. )
  1125. );
  1126. $database["photo"] = array(
  1127. "fields" => array(
  1128. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1129. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1130. "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1131. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  1132. "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1133. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1134. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1135. "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1136. "desc" => array("type" => "text"),
  1137. "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1138. "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1139. "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
  1140. "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
  1141. "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
  1142. "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1143. "data" => array("type" => "mediumblob", "not null" => "1"),
  1144. "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
  1145. "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1146. "allow_cid" => array("type" => "mediumtext"),
  1147. "allow_gid" => array("type" => "mediumtext"),
  1148. "deny_cid" => array("type" => "mediumtext"),
  1149. "deny_gid" => array("type" => "mediumtext"),
  1150. ),
  1151. "indexes" => array(
  1152. "PRIMARY" => array("id"),
  1153. "uid_contactid" => array("uid", "contact-id"),
  1154. "uid_profile" => array("uid", "profile"),
  1155. "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
  1156. "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
  1157. "resource-id" => array("resource-id(64)"),
  1158. )
  1159. );
  1160. $database["poll"] = array(
  1161. "fields" => 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. "q0" => array("type" => "text"),
  1165. "q1" => array("type" => "text"),
  1166. "q2" => array("type" => "text"),
  1167. "q3" => array("type" => "text"),
  1168. "q4" => array("type" => "text"),
  1169. "q5" => array("type" => "text"),
  1170. "q6" => array("type" => "text"),
  1171. "q7" => array("type" => "text"),
  1172. "q8" => array("type" => "text"),
  1173. "q9" => array("type" => "text"),
  1174. ),
  1175. "indexes" => array(
  1176. "PRIMARY" => array("id"),
  1177. "uid" => array("uid"),
  1178. )
  1179. );
  1180. $database["poll_result"] = array(
  1181. "fields" => array(
  1182. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1183. "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1184. "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1185. ),
  1186. "indexes" => array(
  1187. "PRIMARY" => array("id"),
  1188. "poll_id" => array("poll_id"),
  1189. "choice" => array("choice"),
  1190. )
  1191. );
  1192. $database["process"] = array(
  1193. "fields" => array(
  1194. "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
  1195. "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
  1196. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1197. ),
  1198. "indexes" => array(
  1199. "PRIMARY" => array("pid"),
  1200. "command" => array("command"),
  1201. )
  1202. );
  1203. $database["profile"] = array(
  1204. "fields" => array(
  1205. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1206. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1207. "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1208. "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1209. "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1210. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1211. "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1212. "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
  1213. "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1214. "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1215. "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1216. "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1217. "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1218. "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1219. "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1220. "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1221. "with" => array("type" => "text"),
  1222. "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1223. "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1224. "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1225. "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1226. "pub_keywords" => array("type" => "text"),
  1227. "prv_keywords" => array("type" => "text"),
  1228. "likes" => array("type" => "text"),
  1229. "dislikes" => array("type" => "text"),
  1230. "about" => array("type" => "text"),
  1231. "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1232. "music" => array("type" => "text"),
  1233. "book" => array("type" => "text"),
  1234. "tv" => array("type" => "text"),
  1235. "film" => array("type" => "text"),
  1236. "interest" => array("type" => "text"),
  1237. "romance" => array("type" => "text"),
  1238. "work" => array("type" => "text"),
  1239. "education" => array("type" => "text"),
  1240. "contact" => array("type" => "text"),
  1241. "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1242. "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1243. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1244. "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1245. "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1246. "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1247. ),
  1248. "indexes" => array(
  1249. "PRIMARY" => array("id"),
  1250. "uid_is-default" => array("uid", "is-default"),
  1251. )
  1252. );
  1253. $database["profile_check"] = array(
  1254. "fields" => array(
  1255. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1256. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1257. "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1258. "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1259. "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1260. "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1261. ),
  1262. "indexes" => array(
  1263. "PRIMARY" => array("id"),
  1264. )
  1265. );
  1266. $database["push_subscriber"] = array(
  1267. "fields" => array(
  1268. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1269. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1270. "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1271. "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1272. "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1273. "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1274. "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1275. "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1276. ),
  1277. "indexes" => array(
  1278. "PRIMARY" => array("id"),
  1279. )
  1280. );
  1281. $database["queue"] = array(
  1282. "fields" => array(
  1283. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1284. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1285. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1286. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1287. "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1288. "content" => array("type" => "mediumtext"),
  1289. "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1290. ),
  1291. "indexes" => array(
  1292. "PRIMARY" => array("id"),
  1293. "cid" => array("cid"),
  1294. "created" => array("created"),
  1295. "last" => array("last"),
  1296. "network" => array("network"),
  1297. "batch" => array("batch"),
  1298. )
  1299. );
  1300. $database["register"] = array(
  1301. "fields" => array(
  1302. "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1303. "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1304. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1305. "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1306. "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1307. "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
  1308. "note" => array("type" => "text"),
  1309. ),
  1310. "indexes" => array(
  1311. "PRIMARY" => array("id"),
  1312. )
  1313. );
  1314. $database["search"] = array(
  1315. "fields" => array(
  1316. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1317. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1318. "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1319. ),
  1320. "indexes" => array(
  1321. "PRIMARY" => array("id"),
  1322. "uid" => array("uid"),
  1323. )
  1324. );
  1325. $database["session"] = array(
  1326. "fields" => array(
  1327. "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1328. "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  1329. "data" => array("type" => "text"),
  1330. "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1331. ),
  1332. "indexes" => array(
  1333. "PRIMARY" => array("id"),
  1334. "sid" => array("sid(64)"),
  1335. "expire" => array("expire"),
  1336. )
  1337. );
  1338. $database["sign"] = array(
  1339. "fields" => array(
  1340. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1341. "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1342. "signed_text" => array("type" => "mediumtext"),
  1343. "signature" => array("type" => "text"),
  1344. "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1345. ),
  1346. "indexes" => array(
  1347. "PRIMARY" => array("id"),
  1348. "iid" => array("iid"),
  1349. )
  1350. );
  1351. $database["spam"] = array(
  1352. "fields" => array(
  1353. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1354. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1355. "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1356. "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1357. "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1358. "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1359. ),
  1360. "indexes" => array(
  1361. "PRIMARY" => array("id"),
  1362. "uid" => array("uid"),
  1363. "spam" => array("spam"),
  1364. "ham" => array("ham"),
  1365. "term" => array("term"),
  1366. )
  1367. );
  1368. $database["term"] = array(
  1369. "fields" => array(
  1370. "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1371. "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1372. "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
  1373. "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
  1374. "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1375. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1376. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1377. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1378. "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1379. "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1380. "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1381. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1382. ),
  1383. "indexes" => array(
  1384. "PRIMARY" => array("tid"),
  1385. "oid_otype_type_term" => array("oid","otype","type","term"),
  1386. "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
  1387. "uid_otype_type_url" => array("uid","otype","type","url(64)"),
  1388. "guid" => array("guid(64)"),
  1389. )
  1390. );
  1391. $database["thread"] = array(
  1392. "fields" => array(
  1393. "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
  1394. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1395. "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1396. "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1397. "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1398. "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1399. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1400. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1401. "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1402. "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1403. "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1404. "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1405. "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1406. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1407. "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1408. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1409. "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1410. "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1411. "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1412. "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1413. "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  1414. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1415. "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1416. "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1417. "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1418. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1419. ),
  1420. "indexes" => array(
  1421. "PRIMARY" => array("iid"),
  1422. "uid_network_commented" => array("uid","network","commented"),
  1423. "uid_network_created" => array("uid","network","created"),
  1424. "uid_contactid_commented" => array("uid","contact-id","commented"),
  1425. "uid_contactid_created" => array("uid","contact-id","created"),
  1426. "uid_created" => array("uid","created"),
  1427. "uid_commented" => array("uid","commented"),
  1428. )
  1429. );
  1430. $database["tokens"] = array(
  1431. "fields" => array(
  1432. "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
  1433. "secret" => array("type" => "text"),
  1434. "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
  1435. "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1436. "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
  1437. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1438. ),
  1439. "indexes" => array(
  1440. "PRIMARY" => array("id"),
  1441. )
  1442. );
  1443. $database["user"] = array(
  1444. "fields" => array(
  1445. "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1446. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  1447. "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1448. "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1449. "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1450. "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1451. "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1452. "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
  1453. "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
  1454. "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1455. "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1456. "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1457. "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1458. "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1459. "pubkey" => array("type" => "text"),
  1460. "prvkey" => array("type" => "text"),
  1461. "spubkey" => array("type" => "text"),
  1462. "sprvkey" => array("type" => "text"),
  1463. "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1464. "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1465. "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1466. "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1467. "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1468. "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1469. "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
  1470. "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
  1471. "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1472. "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1473. "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1474. "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1475. "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
  1476. "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1477. "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1478. "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1479. "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1480. "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1481. "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1482. "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1483. "allow_cid" => array("type" => "mediumtext"),
  1484. "allow_gid" => array("type" => "mediumtext"),
  1485. "deny_cid" => array("type" => "mediumtext"),
  1486. "deny_gid" => array("type" => "mediumtext"),
  1487. "openidserver" => array("type" => "text"),
  1488. ),
  1489. "indexes" => array(
  1490. "PRIMARY" => array("uid"),
  1491. "nickname" => array("nickname(32)"),
  1492. )
  1493. );
  1494. $database["userd"] = array(
  1495. "fields" => array(
  1496. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1497. "username" => array("type" => "varchar(255)", "not null" => "1"),
  1498. ),
  1499. "indexes" => array(
  1500. "PRIMARY" => array("id"),
  1501. "username" => array("username(32)"),
  1502. )
  1503. );
  1504. $database["workerqueue"] = array(
  1505. "fields" => array(
  1506. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1507. "parameter" => array("type" => "text"),
  1508. "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
  1509. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1510. "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1511. "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1512. ),
  1513. "indexes" => array(
  1514. "PRIMARY" => array("id"),
  1515. )
  1516. );
  1517. return($database);
  1518. }
  1519. /*
  1520. * run from command line
  1521. */
  1522. function dbstructure_run(&$argv, &$argc) {
  1523. global $a, $db;
  1524. if(is_null($a)){
  1525. $a = new App;
  1526. }
  1527. if(is_null($db)) {
  1528. @include(".htconfig.php");
  1529. require_once("include/dba.php");
  1530. $db = new dba($db_host, $db_user, $db_pass, $db_data);
  1531. unset($db_host, $db_user, $db_pass, $db_data);
  1532. }
  1533. if ($argc==2) {
  1534. switch ($argv[1]) {
  1535. case "dryrun":
  1536. update_structure(true, false);
  1537. return;
  1538. case "update":
  1539. update_structure(true, true);
  1540. $build = get_config('system','build');
  1541. if (!x($build)) {
  1542. set_config('system','build',DB_UPDATE_VERSION);
  1543. $build = DB_UPDATE_VERSION;
  1544. }
  1545. $stored = intval($build);
  1546. $current = intval(DB_UPDATE_VERSION);
  1547. // run any left update_nnnn functions in update.php
  1548. for($x = $stored; $x < $current; $x ++) {
  1549. $r = run_update_function($x);
  1550. if (!$r) break;
  1551. }
  1552. set_config('system','build',DB_UPDATE_VERSION);
  1553. return;
  1554. case "dumpsql":
  1555. // For the dump that is used to create the database.sql we always assume utfmb4
  1556. $charset = "utf8mb4";
  1557. print_structure(db_definition($charset), $charset);
  1558. return;
  1559. }
  1560. }
  1561. // print help
  1562. echo $argv[0]." <command>\n";
  1563. echo "\n";
  1564. echo "Commands:\n";
  1565. echo "dryrun show database update schema queries without running them\n";
  1566. echo "update update database schema\n";
  1567. echo "dumpsql dump database schema\n";
  1568. return;
  1569. }
  1570. if (array_search(__file__,get_included_files())===0){
  1571. dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);
  1572. killme();
  1573. }