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.

1580 lines
72 KiB

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