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.

1653 lines
75KB

  1. -- ------------------------------------------
  2. -- Friendica 2020.06-dev (Red Hot Poker)
  3. -- DB_UPDATE_VERSION 1353
  4. -- ------------------------------------------
  5. --
  6. -- TABLE gserver
  7. --
  8. CREATE TABLE IF NOT EXISTS `gserver` (
  9. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  10. `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  11. `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  12. `version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  13. `site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  14. `info` text COMMENT '',
  15. `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
  16. `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
  17. `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
  18. `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  19. `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  20. `network` char(4) NOT NULL DEFAULT '' COMMENT '',
  21. `platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  22. `relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
  23. `relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
  24. `detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
  25. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  26. `last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
  27. `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
  28. `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
  29. PRIMARY KEY(`id`),
  30. UNIQUE INDEX `nurl` (`nurl`(190))
  31. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
  32. --
  33. -- TABLE clients
  34. --
  35. CREATE TABLE IF NOT EXISTS `clients` (
  36. `client_id` varchar(20) NOT NULL COMMENT '',
  37. `pw` varchar(20) NOT NULL DEFAULT '' COMMENT '',
  38. `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
  39. `name` text COMMENT '',
  40. `icon` text COMMENT '',
  41. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  42. PRIMARY KEY(`client_id`)
  43. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
  44. --
  45. -- TABLE contact
  46. --
  47. CREATE TABLE IF NOT EXISTS `contact` (
  48. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  49. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
  50. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  51. `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
  52. `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
  53. `remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
  54. `rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
  55. `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
  56. `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
  57. `protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
  58. `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
  59. `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
  60. `location` varchar(255) DEFAULT '' COMMENT '',
  61. `about` text COMMENT '',
  62. `keywords` text COMMENT 'public keywords (interests) of the contact',
  63. `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
  64. `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  65. `attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  66. `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  67. `photo` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
  68. `thumb` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
  69. `micro` varchar(255) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
  70. `site-pubkey` text COMMENT '',
  71. `issued-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  72. `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  73. `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  74. `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  75. `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  76. `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  77. `pubkey` text COMMENT 'RSA public key 4096 bit',
  78. `prvkey` text COMMENT 'RSA private key 4096 bit',
  79. `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  80. `request` varchar(255) COMMENT '',
  81. `notify` varchar(255) COMMENT '',
  82. `poll` varchar(255) COMMENT '',
  83. `confirm` varchar(255) COMMENT '',
  84. `subscribe` varchar(255) COMMENT '',
  85. `poco` varchar(255) COMMENT '',
  86. `aes_allow` boolean NOT NULL DEFAULT '0' COMMENT '',
  87. `ret-aes` boolean NOT NULL DEFAULT '0' COMMENT '',
  88. `usehub` boolean NOT NULL DEFAULT '0' COMMENT '',
  89. `subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
  90. `hub-verify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  91. `last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
  92. `success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
  93. `failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
  94. `name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  95. `uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  96. `avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  97. `term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  98. `last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
  99. `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  100. `blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
  101. `block_reason` text COMMENT 'Node-wide block reason',
  102. `readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
  103. `writable` boolean NOT NULL DEFAULT '0' COMMENT '',
  104. `forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum',
  105. `prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group',
  106. `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT '',
  107. `hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
  108. `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
  109. `pending` boolean NOT NULL DEFAULT '1' COMMENT '',
  110. `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
  111. `rating` tinyint NOT NULL DEFAULT 0 COMMENT '',
  112. `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
  113. `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
  114. `baseurl` varchar(255) DEFAULT '' COMMENT 'baseurl of the contact',
  115. `gsid` int unsigned COMMENT 'Global Server ID',
  116. `reason` text COMMENT '',
  117. `closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT '',
  118. `info` mediumtext COMMENT '',
  119. `profile-id` int unsigned COMMENT 'Deprecated',
  120. `bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
  121. `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
  122. `notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
  123. `fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  124. `ffi_keyword_denylist` text COMMENT '',
  125. PRIMARY KEY(`id`),
  126. INDEX `uid_name` (`uid`,`name`(190)),
  127. INDEX `self_uid` (`self`,`uid`),
  128. INDEX `alias_uid` (`alias`(32),`uid`),
  129. INDEX `pending_uid` (`pending`,`uid`),
  130. INDEX `blocked_uid` (`blocked`,`uid`),
  131. INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
  132. INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
  133. INDEX `addr_uid` (`addr`(32),`uid`),
  134. INDEX `nurl_uid` (`nurl`(32),`uid`),
  135. INDEX `nick_uid` (`nick`(32),`uid`),
  136. INDEX `dfrn-id` (`dfrn-id`(64)),
  137. INDEX `issued-id` (`issued-id`(64)),
  138. INDEX `gsid` (`gsid`),
  139. FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
  140. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
  141. --
  142. -- TABLE item-uri
  143. --
  144. CREATE TABLE IF NOT EXISTS `item-uri` (
  145. `id` int unsigned NOT NULL auto_increment,
  146. `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
  147. `guid` varbinary(255) COMMENT 'A unique identifier for an item',
  148. PRIMARY KEY(`id`),
  149. UNIQUE INDEX `uri` (`uri`),
  150. INDEX `guid` (`guid`)
  151. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
  152. --
  153. -- TABLE permissionset
  154. --
  155. CREATE TABLE IF NOT EXISTS `permissionset` (
  156. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  157. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
  158. `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
  159. `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
  160. `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
  161. `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
  162. PRIMARY KEY(`id`),
  163. INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
  164. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
  165. --
  166. -- TABLE tag
  167. --
  168. CREATE TABLE IF NOT EXISTS `tag` (
  169. `id` int unsigned NOT NULL auto_increment COMMENT '',
  170. `name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
  171. `url` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
  172. PRIMARY KEY(`id`),
  173. UNIQUE INDEX `type_name_url` (`name`,`url`),
  174. INDEX `url` (`url`)
  175. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
  176. --
  177. -- TABLE 2fa_app_specific_password
  178. --
  179. CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
  180. `id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
  181. `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
  182. `description` varchar(255) COMMENT 'Description of the usage of the password',
  183. `hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
  184. `generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
  185. `last_used` datetime COMMENT 'Datetime the password was last used',
  186. PRIMARY KEY(`id`),
  187. INDEX `uid_description` (`uid`,`description`(190))
  188. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
  189. --
  190. -- TABLE 2fa_recovery_codes
  191. --
  192. CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
  193. `uid` mediumint unsigned NOT NULL COMMENT 'User ID',
  194. `code` varchar(50) NOT NULL COMMENT 'Recovery code string',
  195. `generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
  196. `used` datetime COMMENT 'Datetime the code was used',
  197. PRIMARY KEY(`uid`,`code`)
  198. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
  199. --
  200. -- TABLE addon
  201. --
  202. CREATE TABLE IF NOT EXISTS `addon` (
  203. `id` int unsigned NOT NULL auto_increment COMMENT '',
  204. `name` varchar(50) NOT NULL DEFAULT '' COMMENT 'addon base (file)name',
  205. `version` varchar(50) NOT NULL DEFAULT '' COMMENT 'currently unused',
  206. `installed` boolean NOT NULL DEFAULT '0' COMMENT 'currently always 1',
  207. `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'currently unused',
  208. `timestamp` int unsigned NOT NULL DEFAULT 0 COMMENT 'file timestamp to check for reloads',
  209. `plugin_admin` boolean NOT NULL DEFAULT '0' COMMENT '1 = has admin config, 0 = has no admin config',
  210. PRIMARY KEY(`id`),
  211. UNIQUE INDEX `name` (`name`)
  212. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registered addons';
  213. --
  214. -- TABLE apcontact
  215. --
  216. CREATE TABLE IF NOT EXISTS `apcontact` (
  217. `url` varbinary(255) NOT NULL COMMENT 'URL of the contact',
  218. `uuid` varchar(255) COMMENT '',
  219. `type` varchar(20) NOT NULL COMMENT '',
  220. `following` varchar(255) COMMENT '',
  221. `followers` varchar(255) COMMENT '',
  222. `inbox` varchar(255) NOT NULL COMMENT '',
  223. `outbox` varchar(255) COMMENT '',
  224. `sharedinbox` varchar(255) COMMENT '',
  225. `manually-approve` boolean COMMENT '',
  226. `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  227. `name` varchar(255) COMMENT '',
  228. `about` text COMMENT '',
  229. `photo` varchar(255) COMMENT '',
  230. `addr` varchar(255) COMMENT '',
  231. `alias` varchar(255) COMMENT '',
  232. `pubkey` text COMMENT '',
  233. `subscribe` varchar(255) COMMENT '',
  234. `baseurl` varchar(255) COMMENT 'baseurl of the ap contact',
  235. `gsid` int unsigned COMMENT 'Global Server ID',
  236. `generator` varchar(255) COMMENT 'Name of the contact\'s system',
  237. `following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
  238. `followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
  239. `statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
  240. `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  241. PRIMARY KEY(`url`),
  242. INDEX `addr` (`addr`(32)),
  243. INDEX `alias` (`alias`(190)),
  244. INDEX `followers` (`followers`(190)),
  245. INDEX `gsid` (`gsid`),
  246. FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
  247. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
  248. --
  249. -- TABLE attach
  250. --
  251. CREATE TABLE IF NOT EXISTS `attach` (
  252. `id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
  253. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
  254. `hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
  255. `filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
  256. `filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
  257. `filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
  258. `data` longblob NOT NULL COMMENT 'file data',
  259. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
  260. `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
  261. `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
  262. `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
  263. `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
  264. `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
  265. `backend-class` tinytext COMMENT 'Storage backend class',
  266. `backend-ref` text COMMENT 'Storage backend data reference',
  267. PRIMARY KEY(`id`)
  268. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
  269. --
  270. -- TABLE auth_codes
  271. --
  272. CREATE TABLE IF NOT EXISTS `auth_codes` (
  273. `id` varchar(40) NOT NULL COMMENT '',
  274. `client_id` varchar(20) NOT NULL DEFAULT '' COMMENT '',
  275. `redirect_uri` varchar(200) NOT NULL DEFAULT '' COMMENT '',
  276. `expires` int NOT NULL DEFAULT 0 COMMENT '',
  277. `scope` varchar(250) NOT NULL DEFAULT '' COMMENT '',
  278. PRIMARY KEY(`id`),
  279. INDEX `client_id` (`client_id`),
  280. FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
  281. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
  282. --
  283. -- TABLE cache
  284. --
  285. CREATE TABLE IF NOT EXISTS `cache` (
  286. `k` varbinary(255) NOT NULL COMMENT 'cache key',
  287. `v` mediumtext COMMENT 'cached serialized value',
  288. `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
  289. `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
  290. PRIMARY KEY(`k`),
  291. INDEX `k_expires` (`k`,`expires`)
  292. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
  293. --
  294. -- TABLE challenge
  295. --
  296. CREATE TABLE IF NOT EXISTS `challenge` (
  297. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  298. `challenge` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  299. `dfrn-id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  300. `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  301. `type` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  302. `last_update` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  303. PRIMARY KEY(`id`)
  304. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
  305. --
  306. -- TABLE config
  307. --
  308. CREATE TABLE IF NOT EXISTS `config` (
  309. `id` int unsigned NOT NULL auto_increment COMMENT '',
  310. `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
  311. `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
  312. `v` mediumtext COMMENT '',
  313. PRIMARY KEY(`id`),
  314. UNIQUE INDEX `cat_k` (`cat`,`k`)
  315. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
  316. --
  317. -- TABLE contact-relation
  318. --
  319. CREATE TABLE IF NOT EXISTS `contact-relation` (
  320. `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
  321. `relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
  322. `last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
  323. PRIMARY KEY(`cid`,`relation-cid`),
  324. INDEX `relation-cid` (`relation-cid`)
  325. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
  326. --
  327. -- TABLE conv
  328. --
  329. CREATE TABLE IF NOT EXISTS `conv` (
  330. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  331. `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
  332. `recips` text COMMENT 'sender_handle;recipient_handle',
  333. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
  334. `creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
  335. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
  336. `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
  337. `subject` text COMMENT 'subject of initial message',
  338. PRIMARY KEY(`id`),
  339. INDEX `uid` (`uid`)
  340. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
  341. --
  342. -- TABLE conversation
  343. --
  344. CREATE TABLE IF NOT EXISTS `conversation` (
  345. `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
  346. `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
  347. `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
  348. `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
  349. `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item',
  350. `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull',
  351. `source` mediumtext COMMENT 'Original source',
  352. `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date',
  353. PRIMARY KEY(`item-uri`),
  354. INDEX `conversation-uri` (`conversation-uri`),
  355. INDEX `received` (`received`)
  356. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
  357. --
  358. -- TABLE diaspora-interaction
  359. --
  360. CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
  361. `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
  362. `interaction` mediumtext COMMENT 'The Diaspora interaction',
  363. PRIMARY KEY(`uri-id`),
  364. FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
  365. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
  366. --
  367. -- TABLE event
  368. --
  369. CREATE TABLE IF NOT EXISTS `event` (
  370. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  371. `guid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  372. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
  373. `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact_id (ID of the contact in contact table)',
  374. `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  375. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
  376. `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
  377. `start` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event start time',
  378. `finish` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'event end time',
  379. `summary` text COMMENT 'short description or title of the event',
  380. `desc` text COMMENT 'event description',
  381. `location` text COMMENT 'event location',
  382. `type` varchar(20) NOT NULL DEFAULT '' COMMENT 'event or birthday',
  383. `nofinish` boolean NOT NULL DEFAULT '0' COMMENT 'if event does have no end this is 1',
  384. `adjust` boolean NOT NULL DEFAULT '1' COMMENT 'adjust to timezone of the recipient (0 or 1)',
  385. `ignore` boolean NOT NULL DEFAULT '0' COMMENT '0 or 1',
  386. `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
  387. `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
  388. `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
  389. `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
  390. PRIMARY KEY(`id`),
  391. INDEX `uid_start` (`uid`,`start`)
  392. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events';
  393. --
  394. -- TABLE fcontact
  395. --
  396. CREATE TABLE IF NOT EXISTS `fcontact` (
  397. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  398. `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'unique id',
  399. `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  400. `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  401. `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  402. `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  403. `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  404. `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  405. `batch` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  406. `notify` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  407. `poll` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  408. `confirm` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  409. `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  410. `network` char(4) NOT NULL DEFAULT '' COMMENT '',
  411. `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  412. `pubkey` text COMMENT '',
  413. `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  414. PRIMARY KEY(`id`),
  415. INDEX `addr` (`addr`(32)),
  416. UNIQUE INDEX `url` (`url`(190))
  417. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
  418. --
  419. -- TABLE fsuggest
  420. --
  421. CREATE TABLE IF NOT EXISTS `fsuggest` (
  422. `id` int unsigned NOT NULL auto_increment COMMENT '',
  423. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  424. `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  425. `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  426. `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  427. `request` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  428. `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  429. `note` text COMMENT '',
  430. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  431. PRIMARY KEY(`id`)
  432. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='friend suggestion stuff';
  433. --
  434. -- TABLE gcign
  435. --
  436. CREATE TABLE IF NOT EXISTS `gcign` (
  437. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  438. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Local User id',
  439. `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'gcontact.id of ignored contact',
  440. PRIMARY KEY(`id`),
  441. INDEX `uid` (`uid`),
  442. INDEX `gcid` (`gcid`)
  443. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contacts ignored by friend suggestions';
  444. --
  445. -- TABLE gcontact
  446. --
  447. CREATE TABLE IF NOT EXISTS `gcontact` (
  448. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  449. `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
  450. `nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
  451. `url` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the contacts profile page',
  452. `nurl` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  453. `photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'Link to the profile photo',
  454. `connect` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  455. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  456. `updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
  457. `last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
  458. `last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
  459. `last_discovery` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last contact discovery',
  460. `archive_date` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
  461. `archived` boolean NOT NULL DEFAULT '0' COMMENT '',
  462. `location` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  463. `about` text COMMENT '',
  464. `keywords` text COMMENT 'puplic keywords (interests)',
  465. `gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
  466. `birthday` varchar(32) NOT NULL DEFAULT '0001-01-01' COMMENT '',
  467. `community` boolean NOT NULL DEFAULT '0' COMMENT '1 if contact is forum account',
  468. `contact-type` tinyint NOT NULL DEFAULT -1 COMMENT '',
  469. `hide` boolean NOT NULL DEFAULT '0' COMMENT '1 = should be hidden from search',
  470. `nsfw` boolean NOT NULL DEFAULT '0' COMMENT '1 = contact posts nsfw content',
  471. `network` char(4) NOT NULL DEFAULT '' COMMENT 'social network protocol',
  472. `addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  473. `notify` varchar(255) COMMENT '',
  474. `alias` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  475. `generation` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  476. `server_url` varchar(255) NOT NULL DEFAULT '' COMMENT 'baseurl of the contacts server',
  477. `gsid` int unsigned COMMENT 'Global Server ID',
  478. PRIMARY KEY(`id`),
  479. UNIQUE INDEX `nurl` (`nurl`(190)),
  480. INDEX `name` (`name`(64)),
  481. INDEX `nick` (`nick`(32)),
  482. INDEX `addr` (`addr`(64)),
  483. INDEX `hide_network_updated` (`hide`,`network`,`updated`),
  484. INDEX `updated` (`updated`),
  485. INDEX `gsid` (`gsid`),
  486. FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
  487. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='global contacts';
  488. --
  489. -- TABLE gfollower
  490. --
  491. CREATE TABLE IF NOT EXISTS `gfollower` (
  492. `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact',
  493. `follower-gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact of the follower',
  494. `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates that the connection has been deleted',
  495. PRIMARY KEY(`gcid`,`follower-gcid`),
  496. INDEX `follower-gcid` (`follower-gcid`)
  497. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Followers of global contacts';
  498. --
  499. -- TABLE glink
  500. --
  501. CREATE TABLE IF NOT EXISTS `glink` (
  502. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  503. `cid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  504. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  505. `gcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  506. `zcid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  507. `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  508. PRIMARY KEY(`id`),
  509. UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`),
  510. INDEX `gcid` (`gcid`)
  511. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='\'friends of friends\' linkages derived from poco';
  512. --
  513. -- TABLE group
  514. --
  515. CREATE TABLE IF NOT EXISTS `group` (
  516. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  517. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
  518. `visible` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the member list is not private',
  519. `deleted` boolean NOT NULL DEFAULT '0' COMMENT '1 indicates the group has been deleted',
  520. `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'human readable name of group',
  521. PRIMARY KEY(`id`),
  522. INDEX `uid` (`uid`)
  523. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, group info';
  524. --
  525. -- TABLE group_member
  526. --
  527. CREATE TABLE IF NOT EXISTS `group_member` (
  528. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  529. `gid` int unsigned NOT NULL DEFAULT 0 COMMENT 'groups.id of the associated group',
  530. `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id of the member assigned to the associated group',
  531. PRIMARY KEY(`id`),
  532. INDEX `contactid` (`contact-id`),
  533. UNIQUE INDEX `gid_contactid` (`gid`,`contact-id`)
  534. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='privacy groups, member info';
  535. --
  536. -- TABLE gserver-tag
  537. --
  538. CREATE TABLE IF NOT EXISTS `gserver-tag` (
  539. `gserver-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'The id of the gserver',
  540. `tag` varchar(100) NOT NULL DEFAULT '' COMMENT 'Tag that the server has subscribed',
  541. PRIMARY KEY(`gserver-id`,`tag`),
  542. INDEX `tag` (`tag`)
  543. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Tags that the server has subscribed';
  544. --
  545. -- TABLE hook
  546. --
  547. CREATE TABLE IF NOT EXISTS `hook` (
  548. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  549. `hook` varbinary(100) NOT NULL DEFAULT '' COMMENT 'name of hook',
  550. `file` varbinary(200) NOT NULL DEFAULT '' COMMENT 'relative filename of hook handler',
  551. `function` varbinary(200) NOT NULL DEFAULT '' COMMENT 'function name of hook handler',
  552. `priority` smallint unsigned NOT NULL DEFAULT 0 COMMENT 'not yet implemented - can be used to sort conflicts in hook handling by calling handlers in priority order',
  553. PRIMARY KEY(`id`),
  554. UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`)
  555. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry';
  556. --
  557. -- TABLE inbox-status
  558. --
  559. CREATE TABLE IF NOT EXISTS `inbox-status` (
  560. `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox',
  561. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry',
  562. `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery',
  563. `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery',
  564. `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date',
  565. `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?',
  566. `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?',
  567. PRIMARY KEY(`url`)
  568. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes';
  569. --
  570. -- TABLE intro
  571. --
  572. CREATE TABLE IF NOT EXISTS `intro` (
  573. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  574. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  575. `fid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  576. `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  577. `knowyou` boolean NOT NULL DEFAULT '0' COMMENT '',
  578. `duplex` boolean NOT NULL DEFAULT '0' COMMENT '',
  579. `note` text COMMENT '',
  580. `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  581. `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  582. `blocked` boolean NOT NULL DEFAULT '1' COMMENT '',
  583. `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
  584. PRIMARY KEY(`id`)
  585. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
  586. --
  587. -- TABLE item
  588. --
  589. CREATE TABLE IF NOT EXISTS `item` (
  590. `id` int unsigned NOT NULL auto_increment,
  591. `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
  592. `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  593. `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
  594. `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
  595. `parent` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id of the parent to this item if it is a reply of some form; otherwise this must be set to the id of this item',
  596. `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
  597. `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
  598. `thr-parent` varchar(255) NOT NULL DEFAULT '' COMMENT 'If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri',
  599. `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
  600. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
  601. `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
  602. `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
  603. `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
  604. `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date that something in the conversation changed, indicating clients should fetch the conversation again',
  605. `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  606. `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
  607. `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
  608. `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
  609. `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
  610. `iaid` int unsigned COMMENT 'Id of the item-activity table entry that contains the activity data',
  611. `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
  612. `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  613. `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
  614. `global` boolean NOT NULL DEFAULT '0' COMMENT '',
  615. `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
  616. `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
  617. `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
  618. `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
  619. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
  620. `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
  621. `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
  622. `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
  623. `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
  624. `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited',
  625. `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
  626. `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
  627. `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  628. `psid` int unsigned COMMENT 'ID of the permission set of this post',
  629. `resource-id` varchar(32) NOT NULL DEFAULT '' COMMENT 'Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type',
  630. `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
  631. `attach` mediumtext COMMENT 'JSON structure representing attachments to this item',
  632. `allow_cid` mediumtext COMMENT 'Deprecated',
  633. `allow_gid` mediumtext COMMENT 'Deprecated',
  634. `deny_cid` mediumtext COMMENT 'Deprecated',
  635. `deny_gid` mediumtext COMMENT 'Deprecated',
  636. `postopts` text COMMENT 'Deprecated',
  637. `inform` mediumtext COMMENT 'Deprecated',
  638. `type` varchar(20) COMMENT 'Deprecated',
  639. `bookmark` boolean COMMENT 'Deprecated',
  640. `file` mediumtext COMMENT 'Deprecated',
  641. `location` varchar(255) COMMENT 'Deprecated',
  642. `coord` varchar(255) COMMENT 'Deprecated',
  643. `tag` mediumtext COMMENT 'Deprecated',
  644. `plink` varchar(255) COMMENT 'Deprecated',
  645. `title` varchar(255) COMMENT 'Deprecated',
  646. `content-warning` varchar(255) COMMENT 'Deprecated',
  647. `body` mediumtext COMMENT 'Deprecated',
  648. `app` varchar(255) COMMENT 'Deprecated',
  649. `verb` varchar(100) COMMENT 'Deprecated',
  650. `object-type` varchar(100) COMMENT 'Deprecated',
  651. `object` text COMMENT 'Deprecated',
  652. `target-type` varchar(100) COMMENT 'Deprecated',
  653. `target` text COMMENT 'Deprecated',
  654. `author-name` varchar(255) COMMENT 'Deprecated',
  655. `author-link` varchar(255) COMMENT 'Deprecated',
  656. `author-avatar` varchar(255) COMMENT 'Deprecated',
  657. `owner-name` varchar(255) COMMENT 'Deprecated',
  658. `owner-link` varchar(255) COMMENT 'Deprecated',
  659. `owner-avatar` varchar(255) COMMENT 'Deprecated',
  660. `rendered-hash` varchar(32) COMMENT 'Deprecated',
  661. `rendered-html` mediumtext COMMENT 'Deprecated',
  662. PRIMARY KEY(`id`),
  663. INDEX `guid` (`guid`(191)),
  664. INDEX `uri` (`uri`(191)),
  665. INDEX `parent` (`parent`),
  666. INDEX `parent-uri` (`parent-uri`(191)),
  667. INDEX `extid` (`extid`(191)),
  668. INDEX `uid_id` (`uid`,`id`),
  669. INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
  670. INDEX `uid_received` (`uid`,`received`),
  671. INDEX `uid_commented` (`uid`,`commented`),
  672. INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
  673. INDEX `uid_network_received` (`uid`,`network`,`received`),
  674. INDEX `uid_network_commented` (`uid`,`network`,`commented`),
  675. INDEX `uid_thrparent` (`uid`,`thr-parent`(190)),
  676. INDEX `uid_parenturi` (`uid`,`parent-uri`(190)),
  677. INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
  678. INDEX `authorid_received` (`author-id`,`received`),
  679. INDEX `ownerid` (`owner-id`),
  680. INDEX `contact-id` (`contact-id`),
  681. INDEX `uid_uri` (`uid`,`uri`(190)),
  682. INDEX `resource-id` (`resource-id`),
  683. INDEX `deleted_changed` (`deleted`,`changed`),
  684. INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
  685. INDEX `mention_uid_id` (`mention`,`uid`,`id`),
  686. INDEX `uid_eventid` (`uid`,`event-id`),
  687. INDEX `icid` (`icid`),
  688. INDEX `iaid` (`iaid`),
  689. INDEX `psid_wall` (`psid`,`wall`),
  690. INDEX `uri-id` (`uri-id`),
  691. INDEX `parent-uri-id` (`parent-uri-id`),
  692. INDEX `thr-parent-id` (`thr-parent-id`),
  693. FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
  694. FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
  695. FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
  696. FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
  697. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
  698. --
  699. -- TABLE item-activity
  700. --
  701. CREATE TABLE IF NOT EXISTS `item-activity` (
  702. `id` int unsigned NOT NULL auto_increment,
  703. `uri` varchar(255) COMMENT '',
  704. `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
  705. `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
  706. `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
  707. PRIMARY KEY(`id`),
  708. UNIQUE INDEX `uri-hash` (`uri-hash`),
  709. INDEX `uri` (`uri`(191)),
  710. INDEX `uri-id` (`uri-id`),
  711. FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
  712. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activities for items';
  713. --
  714. -- TABLE item-content
  715. --
  716. CREATE TABLE IF NOT EXISTS `item-content` (
  717. `id` int unsigned NOT NULL auto_increment,
  718. `uri` varchar(255) COMMENT '',
  719. `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
  720. `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
  721. `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
  722. `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  723. `body` mediumtext COMMENT 'item body content',
  724. `location` varchar(255) NOT NULL DEFAULT '' COMMENT 'text location where this item originated',
  725. `coord` varchar(255) NOT NULL DEFAULT '' COMMENT 'longitude/latitude pair representing location where this item originated',
  726. `language` text COMMENT 'Language information about this post',
  727. `app` varchar(255) NOT NULL DEFAULT '' COMMENT 'application which generated this item',
  728. `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '',
  729. `rendered-html` mediumtext COMMENT 'item.body converted to html',
  730. `object-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams object type',
  731. `object` text COMMENT 'JSON encoded object structure unless it is an implied object (normal post)',
  732. `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)',
  733. `target` text COMMENT 'JSON encoded target structure if used',
  734. `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source',
  735. `verb` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams verb',
  736. PRIMARY KEY(`id`),
  737. UNIQUE INDEX `uri-plink-hash` (`uri-plink-hash`),
  738. INDEX `uri` (`uri`(191)),
  739. INDEX `plink` (`plink`(191)),
  740. INDEX `uri-id` (`uri-id`),
  741. FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
  742. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
  743. --
  744. -- TABLE locks
  745. --
  746. CREATE TABLE IF NOT EXISTS `locks` (
  747. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  748. `name` varchar(128) NOT NULL DEFAULT '' COMMENT '',
  749. `locked` boolean NOT NULL DEFAULT '0' COMMENT '',
  750. `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process ID',
  751. `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
  752. PRIMARY KEY(`id`),
  753. INDEX `name_expires` (`name`,`expires`)
  754. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
  755. --
  756. -- TABLE mail
  757. --
  758. CREATE TABLE IF NOT EXISTS `mail` (
  759. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  760. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
  761. `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this private message',
  762. `from-name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the sender',
  763. `from-photo` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact photo link of the sender',
  764. `from-url` varchar(255) NOT NULL DEFAULT '' COMMENT 'profile linke of the sender',
  765. `contact-id` varchar(255) NOT NULL DEFAULT '' COMMENT 'contact.id',
  766. `convid` int unsigned NOT NULL DEFAULT 0 COMMENT 'conv.id',
  767. `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  768. `body` mediumtext COMMENT '',
  769. `seen` boolean NOT NULL DEFAULT '0' COMMENT 'if message visited it is 1',
  770. `reply` boolean NOT NULL DEFAULT '0' COMMENT '',
  771. `replied` boolean NOT NULL DEFAULT '0' COMMENT '',
  772. `unknown` boolean NOT NULL DEFAULT '0' COMMENT 'if sender not in the contact table this is 1',
  773. `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  774. `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  775. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time of the private message',
  776. PRIMARY KEY(`id`),
  777. INDEX `uid_seen` (`uid`,`seen`),
  778. INDEX `convid` (`convid`),
  779. INDEX `uri` (`uri`(64)),
  780. INDEX `parent-uri` (`parent-uri`(64)),
  781. INDEX `contactid` (`contact-id`(32))
  782. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
  783. --
  784. -- TABLE mailacct
  785. --
  786. CREATE TABLE IF NOT EXISTS `mailacct` (
  787. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  788. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  789. `server` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  790. `port` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
  791. `ssltype` varchar(16) NOT NULL DEFAULT '' COMMENT '',
  792. `mailbox` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  793. `user` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  794. `pass` text COMMENT '',
  795. `reply_to` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  796. `action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  797. `movetofolder` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  798. `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
  799. `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  800. PRIMARY KEY(`id`)
  801. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Mail account data for fetching mails';
  802. --
  803. -- TABLE manage
  804. --
  805. CREATE TABLE IF NOT EXISTS `manage` (
  806. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  807. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  808. `mid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  809. PRIMARY KEY(`id`),
  810. UNIQUE INDEX `uid_mid` (`uid`,`mid`)
  811. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='table of accounts that can manage each other';
  812. --
  813. -- TABLE notify
  814. --
  815. CREATE TABLE IF NOT EXISTS `notify` (
  816. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  817. `type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
  818. `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  819. `url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  820. `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  821. `date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  822. `msg` mediumtext COMMENT '',
  823. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
  824. `link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  825. `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'item.id',
  826. `parent` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  827. `uri-id` int unsigned COMMENT 'Item-uri id of the related post',
  828. `parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
  829. `seen` boolean NOT NULL DEFAULT '0' COMMENT '',
  830. `verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
  831. `otype` varchar(10) NOT NULL DEFAULT '' COMMENT '',
  832. `name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
  833. `msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
  834. PRIMARY KEY(`id`),
  835. INDEX `seen_uid_date` (`seen`,`uid`,`date`),
  836. INDEX `uid_date` (`uid`,`date`),
  837. INDEX `uid_type_link` (`uid`,`type`,`link`(190))
  838. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='notifications';
  839. --
  840. -- TABLE notify-threads
  841. --
  842. CREATE TABLE IF NOT EXISTS `notify-threads` (
  843. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  844. `notify-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  845. `master-parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  846. `master-parent-uri-id` int unsigned COMMENT 'Item-uri id of the parent of the related post',
  847. `parent-item` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  848. `receiver-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  849. PRIMARY KEY(`id`),
  850. INDEX `master-parent-uri-id` (`master-parent-uri-id`)
  851. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
  852. --
  853. -- TABLE oembed
  854. --
  855. CREATE TABLE IF NOT EXISTS `oembed` (
  856. `url` varbinary(255) NOT NULL COMMENT 'page url',
  857. `maxwidth` mediumint unsigned NOT NULL COMMENT 'Maximum width passed to Oembed',
  858. `content` mediumtext COMMENT 'OEmbed data of the page',
  859. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
  860. PRIMARY KEY(`url`,`maxwidth`),
  861. INDEX `created` (`created`)
  862. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for OEmbed queries';
  863. --
  864. -- TABLE openwebauth-token
  865. --
  866. CREATE TABLE IF NOT EXISTS `openwebauth-token` (
  867. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  868. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  869. `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Verify type',
  870. `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'A generated token',
  871. `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  872. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
  873. PRIMARY KEY(`id`)
  874. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts';
  875. --
  876. -- TABLE parsed_url
  877. --
  878. CREATE TABLE IF NOT EXISTS `parsed_url` (
  879. `url` varbinary(255) NOT NULL COMMENT 'page url',
  880. `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?',
  881. `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?',
  882. `content` mediumtext COMMENT 'page data',
  883. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation',
  884. PRIMARY KEY(`url`,`guessing`,`oembed`),
  885. INDEX `created` (`created`)
  886. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries';
  887. --
  888. -- TABLE participation
  889. --
  890. CREATE TABLE IF NOT EXISTS `participation` (
  891. `iid` int unsigned NOT NULL COMMENT '',
  892. `server` varchar(60) NOT NULL COMMENT '',
  893. `cid` int unsigned NOT NULL COMMENT '',
  894. `fid` int unsigned NOT NULL COMMENT '',
  895. PRIMARY KEY(`iid`,`server`),
  896. INDEX `cid` (`cid`),
  897. INDEX `fid` (`fid`)
  898. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Storage for participation messages from Diaspora';
  899. --
  900. -- TABLE pconfig
  901. --
  902. CREATE TABLE IF NOT EXISTS `pconfig` (
  903. `id` int unsigned NOT NULL auto_increment COMMENT '',
  904. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  905. `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '',
  906. `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '',
  907. `v` mediumtext COMMENT '',
  908. PRIMARY KEY(`id`),
  909. UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
  910. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
  911. --
  912. -- TABLE photo
  913. --
  914. CREATE TABLE IF NOT EXISTS `photo` (
  915. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  916. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
  917. `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
  918. `guid` char(16) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this photo',
  919. `resource-id` char(32) NOT NULL DEFAULT '' COMMENT '',
  920. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation date',
  921. `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edited date',
  922. `title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  923. `desc` text COMMENT '',
  924. `album` varchar(255) NOT NULL DEFAULT '' COMMENT 'The name of the album to which the photo belongs',
  925. `filename` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  926. `type` varchar(30) NOT NULL DEFAULT 'image/jpeg',
  927. `height` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
  928. `width` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
  929. `datasize` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  930. `data` mediumblob NOT NULL COMMENT '',
  931. `scale` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  932. `profile` boolean NOT NULL DEFAULT '0' COMMENT '',
  933. `allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
  934. `allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
  935. `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
  936. `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
  937. `accessible` boolean NOT NULL DEFAULT '0' COMMENT 'Make photo publicly accessible, ignoring permissions',
  938. `backend-class` tinytext COMMENT 'Storage backend class',
  939. `backend-ref` text COMMENT 'Storage backend data reference',
  940. `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  941. PRIMARY KEY(`id`),
  942. INDEX `contactid` (`contact-id`),
  943. INDEX `uid_contactid` (`uid`,`contact-id`),
  944. INDEX `uid_profile` (`uid`,`profile`),
  945. INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
  946. INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`),
  947. INDEX `resource-id` (`resource-id`)
  948. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage';
  949. --
  950. -- TABLE poll
  951. --
  952. CREATE TABLE IF NOT EXISTS `poll` (
  953. `id` int unsigned NOT NULL auto_increment COMMENT '',
  954. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  955. `q0` text COMMENT '',
  956. `q1` text COMMENT '',
  957. `q2` text COMMENT '',
  958. `q3` text COMMENT '',
  959. `q4` text COMMENT '',
  960. `q5` text COMMENT '',
  961. `q6` text COMMENT '',
  962. `q7` text COMMENT '',
  963. `q8` text COMMENT '',
  964. `q9` text COMMENT '',
  965. PRIMARY KEY(`id`),
  966. INDEX `uid` (`uid`)
  967. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently unused table for storing poll results';
  968. --
  969. -- TABLE poll_result
  970. --
  971. CREATE TABLE IF NOT EXISTS `poll_result` (
  972. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  973. `poll_id` int unsigned NOT NULL DEFAULT 0,
  974. `choice` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  975. PRIMARY KEY(`id`),
  976. INDEX `poll_id` (`poll_id`)
  977. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='data for polls - currently unused';
  978. --
  979. -- TABLE post-category
  980. --
  981. CREATE TABLE IF NOT EXISTS `post-category` (
  982. `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
  983. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  984. `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  985. `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  986. PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`),
  987. INDEX `uri-id` (`tid`),
  988. FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
  989. FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
  990. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories';
  991. --
  992. -- TABLE post-delivery-data
  993. --
  994. CREATE TABLE IF NOT EXISTS `post-delivery-data` (
  995. `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
  996. `postopts` text COMMENT 'External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery',
  997. `inform` mediumtext COMMENT 'Additional receivers of the linked item',
  998. `queue_count` mediumint NOT NULL DEFAULT 0 COMMENT 'Initial number of delivery recipients, used as item.delivery_queue_count',
  999. `queue_done` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries, used as item.delivery_queue_done',
  1000. `queue_failed` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of unsuccessful deliveries, used as item.delivery_queue_failed',
  1001. `activitypub` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via ActivityPub',
  1002. `dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via DFRN',
  1003. `legacy_dfrn` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via legacy DFRN',
  1004. `diaspora` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via Diaspora',
  1005. `ostatus` mediumint NOT NULL DEFAULT 0 COMMENT 'Number of successful deliveries via OStatus',
  1006. PRIMARY KEY(`uri-id`),
  1007. FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
  1008. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
  1009. --
  1010. -- TABLE post-tag
  1011. --
  1012. CREATE TABLE IF NOT EXISTS `post-tag` (
  1013. `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
  1014. `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  1015. `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  1016. `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the mentioned public contact',
  1017. PRIMARY KEY(`uri-id`,`type`,`tid`,`cid`),
  1018. INDEX `tid` (`tid`),
  1019. INDEX `cid` (`cid`),
  1020. FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
  1021. FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
  1022. FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
  1023. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags';
  1024. --
  1025. -- TABLE process
  1026. --
  1027. CREATE TABLE IF NOT EXISTS `process` (
  1028. `pid` int unsigned NOT NULL COMMENT '',
  1029. `command` varbinary(32) NOT NULL DEFAULT '' COMMENT '',
  1030. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  1031. PRIMARY KEY(`pid`),
  1032. INDEX `command` (`command`)
  1033. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Currently running system processes';
  1034. --
  1035. -- TABLE profile
  1036. --
  1037. CREATE TABLE IF NOT EXISTS `profile` (
  1038. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  1039. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
  1040. `profile-name` varchar(255) COMMENT 'Deprecated',
  1041. `is-default` boolean COMMENT 'Deprecated',
  1042. `hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
  1043. `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1044. `pdesc` varchar(255) COMMENT 'Deprecated',
  1045. `dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
  1046. `address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1047. `locality` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1048. `region` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1049. `postal-code` varchar(32) NOT NULL DEFAULT '' COMMENT '',
  1050. `country-name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1051. `hometown` varchar(255) COMMENT 'Deprecated',
  1052. `gender` varchar(32) COMMENT 'Deprecated',
  1053. `marital` varchar(255) COMMENT 'Deprecated',
  1054. `with` text COMMENT 'Deprecated',
  1055. `howlong` datetime COMMENT 'Deprecated',
  1056. `sexual` varchar(255) COMMENT 'Deprecated',
  1057. `politic` varchar(255) COMMENT 'Deprecated',
  1058. `religion` varchar(255) COMMENT 'Deprecated',
  1059. `pub_keywords` text COMMENT '',
  1060. `prv_keywords` text COMMENT '',
  1061. `likes` text COMMENT 'Deprecated',
  1062. `dislikes` text COMMENT 'Deprecated',
  1063. `about` text COMMENT 'Profile description',
  1064. `summary` varchar(255) COMMENT 'Deprecated',
  1065. `music` text COMMENT 'Deprecated',
  1066. `book` text COMMENT 'Deprecated',
  1067. `tv` text COMMENT 'Deprecated',
  1068. `film` text COMMENT 'Deprecated',
  1069. `interest` text COMMENT 'Deprecated',
  1070. `romance` text COMMENT 'Deprecated',
  1071. `work` text COMMENT 'Deprecated',
  1072. `education` text COMMENT 'Deprecated',
  1073. `contact` text COMMENT 'Deprecated',
  1074. `homepage` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1075. `xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1076. `photo` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1077. `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1078. `publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish default profile in local directory',
  1079. `net-publish` boolean NOT NULL DEFAULT '0' COMMENT 'publish profile in global directory',
  1080. PRIMARY KEY(`id`),
  1081. INDEX `uid_is-default` (`uid`,`is-default`),
  1082. FULLTEXT INDEX `pub_keywords` (`pub_keywords`)
  1083. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data';
  1084. --
  1085. -- TABLE profile_check
  1086. --
  1087. CREATE TABLE IF NOT EXISTS `profile_check` (
  1088. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  1089. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  1090. `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
  1091. `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1092. `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1093. `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  1094. PRIMARY KEY(`id`)
  1095. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use';
  1096. --
  1097. -- TABLE profile_field
  1098. --
  1099. CREATE TABLE IF NOT EXISTS `profile_field` (
  1100. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  1101. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner user id',
  1102. `order` mediumint unsigned NOT NULL DEFAULT 1 COMMENT 'Field ordering per user',
  1103. `psid` int unsigned COMMENT 'ID of the permission set of this profile field - 0 = public',
  1104. `label` varchar(255) NOT NULL DEFAULT '' COMMENT 'Label of the field',
  1105. `value` text COMMENT 'Value of the field',
  1106. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
  1107. `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
  1108. PRIMARY KEY(`id`),
  1109. INDEX `uid` (`uid`),
  1110. INDEX `order` (`order`),
  1111. INDEX `psid` (`psid`),
  1112. FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
  1113. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Custom profile fields';
  1114. --
  1115. -- TABLE push_subscriber
  1116. --
  1117. CREATE TABLE IF NOT EXISTS `push_subscriber` (
  1118. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  1119. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  1120. `callback_url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1121. `topic` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1122. `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1123. `push` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
  1124. `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last successful trial',
  1125. `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
  1126. `renewed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last subscription renewal',
  1127. `secret` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1128. PRIMARY KEY(`id`),
  1129. INDEX `next_try` (`next_try`)
  1130. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Used for OStatus: Contains feed subscribers';
  1131. --
  1132. -- TABLE register
  1133. --
  1134. CREATE TABLE IF NOT EXISTS `register` (
  1135. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  1136. `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1137. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  1138. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  1139. `password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1140. `language` varchar(16) NOT NULL DEFAULT '' COMMENT '',
  1141. `note` text COMMENT '',
  1142. PRIMARY KEY(`id`)
  1143. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval';
  1144. --
  1145. -- TABLE search
  1146. --
  1147. CREATE TABLE IF NOT EXISTS `search` (
  1148. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  1149. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  1150. `term` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1151. PRIMARY KEY(`id`),
  1152. INDEX `uid` (`uid`)
  1153. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
  1154. --
  1155. -- TABLE session
  1156. --
  1157. CREATE TABLE IF NOT EXISTS `session` (
  1158. `id` bigint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  1159. `sid` varbinary(255) NOT NULL DEFAULT '' COMMENT '',
  1160. `data` text COMMENT '',
  1161. `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  1162. PRIMARY KEY(`id`),
  1163. INDEX `sid` (`sid`(64)),
  1164. INDEX `expire` (`expire`)
  1165. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='web session storage';
  1166. --
  1167. -- TABLE storage
  1168. --
  1169. CREATE TABLE IF NOT EXISTS `storage` (
  1170. `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented image data id',
  1171. `data` longblob NOT NULL COMMENT 'file data',
  1172. PRIMARY KEY(`id`)
  1173. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Data stored by Database storage backend';
  1174. --
  1175. -- TABLE thread
  1176. --
  1177. CREATE TABLE IF NOT EXISTS `thread` (
  1178. `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'sequential ID',
  1179. `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
  1180. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  1181. `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  1182. `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
  1183. `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
  1184. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  1185. `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  1186. `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  1187. `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  1188. `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
  1189. `wall` boolean NOT NULL DEFAULT '0' COMMENT '',
  1190. `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
  1191. `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
  1192. `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
  1193. `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
  1194. `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
  1195. `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
  1196. `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
  1197. `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
  1198. `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
  1199. `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
  1200. `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  1201. `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
  1202. `network` char(4) NOT NULL DEFAULT '' COMMENT '',
  1203. `bookmark` boolean COMMENT '',
  1204. PRIMARY KEY(`iid`),
  1205. INDEX `uid_network_commented` (`uid`,`network`,`commented`),
  1206. INDEX `uid_network_received` (`uid`,`network`,`received`),
  1207. INDEX `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
  1208. INDEX `uid_contactid_received` (`uid`,`contact-id`,`received`),
  1209. INDEX `contactid` (`contact-id`),
  1210. INDEX `ownerid` (`owner-id`),
  1211. INDEX `authorid` (`author-id`),
  1212. INDEX `uid_received` (`uid`,`received`),
  1213. INDEX `uid_commented` (`uid`,`commented`),
  1214. INDEX `uid_wall_received` (`uid`,`wall`,`received`),
  1215. INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`),
  1216. INDEX `uri-id` (`uri-id`),
  1217. FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
  1218. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data';
  1219. --
  1220. -- TABLE tokens
  1221. --
  1222. CREATE TABLE IF NOT EXISTS `tokens` (
  1223. `id` varchar(40) NOT NULL COMMENT '',
  1224. `secret` text COMMENT '',
  1225. `client_id` varchar(20) NOT NULL DEFAULT '',
  1226. `expires` int NOT NULL DEFAULT 0 COMMENT '',
  1227. `scope` varchar(200) NOT NULL DEFAULT '' COMMENT '',
  1228. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  1229. PRIMARY KEY(`id`),
  1230. INDEX `client_id` (`client_id`),
  1231. FOREIGN KEY (`client_id`) REFERENCES `clients` (`client_id`) ON UPDATE RESTRICT ON DELETE CASCADE
  1232. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth usage';
  1233. --
  1234. -- TABLE user
  1235. --
  1236. CREATE TABLE IF NOT EXISTS `user` (
  1237. `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  1238. `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
  1239. `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
  1240. `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
  1241. `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
  1242. `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
  1243. `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
  1244. `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
  1245. `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
  1246. `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
  1247. `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
  1248. `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
  1249. `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
  1250. `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
  1251. `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
  1252. `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
  1253. `pubkey` text COMMENT 'RSA public key 4096 bit',
  1254. `prvkey` text COMMENT 'RSA private key 4096 bit',
  1255. `spubkey` text COMMENT '',
  1256. `sprvkey` text COMMENT '',
  1257. `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
  1258. `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
  1259. `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
  1260. `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
  1261. `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
  1262. `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
  1263. `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
  1264. `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
  1265. `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
  1266. `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  1267. `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
  1268. `pwdreset` varchar(255) COMMENT 'Password reset request token',
  1269. `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
  1270. `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
  1271. `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  1272. `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
  1273. `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
  1274. `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
  1275. `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
  1276. `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
  1277. `allow_cid` mediumtext COMMENT 'default permission for this user',
  1278. `allow_gid` mediumtext COMMENT 'default permission for this user',
  1279. `deny_cid` mediumtext COMMENT 'default permission for this user',
  1280. `deny_gid` mediumtext COMMENT 'default permission for this user',
  1281. `openidserver` text COMMENT '',
  1282. PRIMARY KEY(`uid`),
  1283. INDEX `nickname` (`nickname`(32))
  1284. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
  1285. --
  1286. -- TABLE userd
  1287. --
  1288. CREATE TABLE IF NOT EXISTS `userd` (
  1289. `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
  1290. `username` varchar(255) NOT NULL COMMENT '',
  1291. PRIMARY KEY(`id`),
  1292. INDEX `username` (`username`(32))
  1293. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
  1294. --
  1295. -- TABLE user-contact
  1296. --
  1297. CREATE TABLE IF NOT EXISTS `user-contact` (
  1298. `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
  1299. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  1300. `blocked` boolean COMMENT 'Contact is completely blocked for this user',
  1301. `ignored` boolean COMMENT 'Posts from this contact are ignored',
  1302. `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
  1303. PRIMARY KEY(`uid`,`cid`)
  1304. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
  1305. --
  1306. -- TABLE user-item
  1307. --
  1308. CREATE TABLE IF NOT EXISTS `user-item` (
  1309. `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
  1310. `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
  1311. `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
  1312. `ignored` boolean COMMENT 'Ignore this thread if set',
  1313. `pinned` boolean COMMENT 'The item is pinned on the profile page',
  1314. `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
  1315. PRIMARY KEY(`uid`,`iid`),
  1316. INDEX `uid_pinned` (`uid`,`pinned`),
  1317. INDEX `iid_uid` (`iid`,`uid`)
  1318. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
  1319. --
  1320. -- TABLE verb
  1321. --
  1322. CREATE TABLE IF NOT EXISTS `verb` (
  1323. `id` smallint unsigned NOT NULL auto_increment,
  1324. `name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
  1325. PRIMARY KEY(`id`)
  1326. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
  1327. --
  1328. -- TABLE worker-ipc
  1329. --
  1330. CREATE TABLE IF NOT EXISTS `worker-ipc` (
  1331. `key` int NOT NULL COMMENT '',
  1332. `jobs` boolean COMMENT 'Flag for outstanding jobs',
  1333. PRIMARY KEY(`key`)
  1334. ) ENGINE=MEMORY DEFAULT COLLATE utf8mb4_general_ci COMMENT='Inter process communication between the frontend and the worker';
  1335. --
  1336. -- TABLE workerqueue
  1337. --
  1338. CREATE TABLE IF NOT EXISTS `workerqueue` (
  1339. `id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
  1340. `parameter` mediumtext COMMENT 'Task command',
  1341. `priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
  1342. `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
  1343. `pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
  1344. `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
  1345. `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
  1346. `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
  1347. `done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
  1348. PRIMARY KEY(`id`),
  1349. INDEX `done_parameter` (`done`,`parameter`(64)),
  1350. INDEX `done_executed` (`done`,`executed`),
  1351. INDEX `done_priority_created` (`done`,`priority`,`created`),
  1352. INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
  1353. INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
  1354. INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
  1355. ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
  1356. --
  1357. -- VIEW category-view
  1358. --
  1359. DROP VIEW IF EXISTS `category-view`;
  1360. CREATE VIEW `category-view` AS SELECT
  1361. `post-category`.`uri-id` AS `uri-id`,
  1362. `post-category`.`uid` AS `uid`,
  1363. `item-uri`.`uri` AS `uri`,
  1364. `item-uri`.`guid` AS `guid`,
  1365. `post-category`.`type` AS `type`,
  1366. `post-category`.`tid` AS `tid`,
  1367. `tag`.`name` AS `name`,
  1368. `tag`.`url` AS `url`
  1369. FROM `post-category`
  1370. INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
  1371. LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`;
  1372. --
  1373. -- VIEW tag-view
  1374. --
  1375. DROP VIEW IF EXISTS `tag-view`;
  1376. CREATE VIEW `tag-view` AS SELECT
  1377. `post-tag`.`uri-id` AS `uri-id`,
  1378. `item-uri`.`uri` AS `uri`,
  1379. `item-uri`.`guid` AS `guid`,
  1380. `post-tag`.`type` AS `type`,
  1381. `post-tag`.`tid` AS `tid`,
  1382. `post-tag`.`cid` AS `cid`,
  1383. CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END AS `name`,
  1384. CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END AS `url`
  1385. FROM `post-tag`
  1386. INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
  1387. LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
  1388. LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`;
  1389. --
  1390. -- VIEW owner-view
  1391. --
  1392. DROP VIEW IF EXISTS `owner-view`;
  1393. CREATE VIEW `owner-view` AS SELECT
  1394. `contact`.`id` AS `id`,
  1395. `contact`.`uid` AS `uid`,
  1396. `contact`.`created` AS `created`,
  1397. `contact`.`updated` AS `updated`,
  1398. `contact`.`self` AS `self`,
  1399. `contact`.`remote_self` AS `remote_self`,
  1400. `contact`.`rel` AS `rel`,
  1401. `contact`.`duplex` AS `duplex`,
  1402. `contact`.`network` AS `network`,
  1403. `contact`.`protocol` AS `protocol`,
  1404. `contact`.`name` AS `name`,
  1405. `contact`.`nick` AS `nick`,
  1406. `contact`.`location` AS `location`,
  1407. `contact`.`about` AS `about`,
  1408. `contact`.`keywords` AS `keywords`,
  1409. `contact`.`gender` AS `gender`,
  1410. `contact`.`xmpp` AS `xmpp`,
  1411. `contact`.`attag` AS `attag`,
  1412. `contact`.`avatar` AS `avatar`,
  1413. `contact`.`photo` AS `photo`,
  1414. `contact`.`thumb` AS `thumb`,
  1415. `contact`.`micro` AS `micro`,
  1416. `contact`.`site-pubkey` AS `site-pubkey`,
  1417. `contact`.`issued-id` AS `issued-id`,
  1418. `contact`.`dfrn-id` AS `dfrn-id`,
  1419. `contact`.`url` AS `url`,
  1420. `contact`.`nurl` AS `nurl`,
  1421. `contact`.`addr` AS `addr`,
  1422. `contact`.`alias` AS `alias`,
  1423. `contact`.`pubkey` AS `pubkey`,
  1424. `contact`.`prvkey` AS `prvkey`,
  1425. `contact`.`batch` AS `batch`,
  1426. `contact`.`request` AS `request`,
  1427. `contact`.`notify` AS `notify`,
  1428. `contact`.`poll` AS `poll`,
  1429. `contact`.`confirm` AS `confirm`,
  1430. `contact`.`poco` AS `poco`,
  1431. `contact`.`aes_allow` AS `aes_allow`,
  1432. `contact`.`ret-aes` AS `ret-aes`,
  1433. `contact`.`usehub` AS `usehub`,
  1434. `contact`.`subhub` AS `subhub`,
  1435. `contact`.`hub-verify` AS `hub-verify`,
  1436. `contact`.`last-update` AS `last-update`,
  1437. `contact`.`success_update` AS `success_update`,
  1438. `contact`.`failure_update` AS `failure_update`,
  1439. `contact`.`name-date` AS `name-date`,
  1440. `contact`.`uri-date` AS `uri-date`,
  1441. `contact`.`avatar-date` AS `avatar-date`,
  1442. `contact`.`avatar-date` AS `picdate`,
  1443. `contact`.`term-date` AS `term-date`,
  1444. `contact`.`last-item` AS `last-item`,
  1445. `contact`.`priority` AS `priority`,
  1446. `contact`.`blocked` AS `blocked`,
  1447. `contact`.`block_reason` AS `block_reason`,
  1448. `contact`.`readonly` AS `readonly`,
  1449. `contact`.`writable` AS `writable`,
  1450. `contact`.`forum` AS `forum`,
  1451. `contact`.`prv` AS `prv`,
  1452. `contact`.`contact-type` AS `contact-type`,
  1453. `contact`.`hidden` AS `hidden`,
  1454. `contact`.`archive` AS `archive`,
  1455. `contact`.`pending` AS `pending`,
  1456. `contact`.`deleted` AS `deleted`,
  1457. `contact`.`rating` AS `rating`,
  1458. `contact`.`unsearchable` AS `unsearchable`,
  1459. `contact`.`sensitive` AS `sensitive`,
  1460. `contact`.`baseurl` AS `baseurl`,
  1461. `contact`.`reason` AS `reason`,
  1462. `contact`.`closeness` AS `closeness`,
  1463. `contact`.`info` AS `info`,
  1464. `contact`.`profile-id` AS `profile-id`,
  1465. `contact`.`bdyear` AS `bdyear`,
  1466. `contact`.`bd` AS `bd`,
  1467. `contact`.`notify_new_posts` AS `notify_new_posts`,
  1468. `contact`.`fetch_further_information` AS `fetch_further_information`,
  1469. `contact`.`ffi_keyword_denylist` AS `ffi_keyword_denylist`,
  1470. `user`.`parent-uid` AS `parent-uid`,
  1471. `user`.`guid` AS `guid`,
  1472. `user`.`nickname` AS `nickname`,
  1473. `user`.`email` AS `email`,
  1474. `user`.`openid` AS `openid`,
  1475. `user`.`timezone` AS `timezone`,
  1476. `user`.`language` AS `language`,
  1477. `user`.`register_date` AS `register_date`,
  1478. `user`.`login_date` AS `login_date`,
  1479. `user`.`default-location` AS `default-location`,
  1480. `user`.`allow_location` AS `allow_location`,
  1481. `user`.`theme` AS `theme`,
  1482. `user`.`pubkey` AS `upubkey`,
  1483. `user`.`prvkey` AS `uprvkey`,
  1484. `user`.`sprvkey` AS `sprvkey`,
  1485. `user`.`spubkey` AS `spubkey`,
  1486. `user`.`verified` AS `verified`,
  1487. `user`.`blockwall` AS `blockwall`,
  1488. `user`.`hidewall` AS `hidewall`,
  1489. `user`.`blocktags` AS `blocktags`,
  1490. `user`.`unkmail` AS `unkmail`,
  1491. `user`.`cntunkmail` AS `cntunkmail`,
  1492. `user`.`notify-flags` AS `notify-flags`,
  1493. `user`.`page-flags` AS `page-flags`,
  1494. `user`.`account-type` AS `account-type`,
  1495. `user`.`prvnets` AS `prvnets`,
  1496. `user`.`maxreq` AS `maxreq`,
  1497. `user`.`expire` AS `expire`,
  1498. `user`.`account_removed` AS `account_removed`,
  1499. `user`.`account_expired` AS `account_expired`,
  1500. `user`.`account_expires_on` AS `account_expires_on`,
  1501. `user`.`expire_notification_sent` AS `expire_notification_sent`,
  1502. `user`.`def_gid` AS `def_gid`,
  1503. `user`.`allow_cid` AS `allow_cid`,
  1504. `user`.`allow_gid` AS `allow_gid`,
  1505. `user`.`deny_cid` AS `deny_cid`,
  1506. `user`.`deny_gid` AS `deny_gid`,
  1507. `user`.`openidserver` AS `openidserver`,
  1508. `profile`.`publish` AS `publish`,
  1509. `profile`.`net-publish` AS `net-publish`,
  1510. `profile`.`hide-friends` AS `hide-friends`,
  1511. `profile`.`prv_keywords` AS `prv_keywords`,
  1512. `profile`.`pub_keywords` AS `pub_keywords`,
  1513. `profile`.`address` AS `address`,
  1514. `profile`.`locality` AS `locality`,
  1515. `profile`.`region` AS `region`,
  1516. `profile`.`postal-code` AS `postal-code`,
  1517. `profile`.`country-name` AS `country-name`,
  1518. `profile`.`homepage` AS `homepage`,
  1519. `profile`.`dob` AS `dob`
  1520. FROM `user`
  1521. INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
  1522. INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`;
  1523. --
  1524. -- VIEW pending-view
  1525. --
  1526. DROP VIEW IF EXISTS `pending-view`;
  1527. CREATE VIEW `pending-view` AS SELECT
  1528. `register`.`id` AS `id`,
  1529. `register`.`hash` AS `hash`,
  1530. `register`.`created` AS `created`,
  1531. `register`.`uid` AS `uid`,
  1532. `register`.`password` AS `password`,
  1533. `register`.`language` AS `language`,
  1534. `register`.`note` AS `note`,
  1535. `contact`.`self` AS `self`,
  1536. `contact`.`name` AS `name`,
  1537. `contact`.`url` AS `url`,
  1538. `contact`.`micro` AS `micro`,
  1539. `user`.`email` AS `email`,
  1540. `contact`.`nick` AS `nick`
  1541. FROM `register`
  1542. INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
  1543. INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
  1544. --
  1545. -- VIEW tag-search-view
  1546. --
  1547. DROP VIEW IF EXISTS `tag-search-view`;
  1548. CREATE VIEW `tag-search-view` AS SELECT
  1549. `post-tag`.`uri-id` AS `uri-id`,
  1550. `item`.`id` AS `iid`,
  1551. `item`.`uri` AS `uri`,
  1552. `item`.`guid` AS `guid`,
  1553. `item`.`uid` AS `uid`,
  1554. `item`.`private` AS `private`,
  1555. `item`.`wall` AS `wall`,
  1556. `item`.`origin` AS `origin`,
  1557. `item`.`gravity` AS `gravity`,
  1558. `item`.`received` AS `received`,
  1559. `tag`.`name` AS `name`
  1560. FROM `post-tag`
  1561. INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
  1562. INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
  1563. WHERE `post-tag`.`type` = 1;
  1564. --
  1565. -- VIEW workerqueue-view
  1566. --
  1567. DROP VIEW IF EXISTS `workerqueue-view`;
  1568. CREATE VIEW `workerqueue-view` AS SELECT
  1569. `process`.`pid` AS `pid`,
  1570. `workerqueue`.`priority` AS `priority`
  1571. FROM `process`
  1572. INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
  1573. WHERE NOT `workerqueue`.`done`;