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.

1500 lines
71KB

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