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.
 
 
 
 
 
 

1684 lines
79 KiB

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