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.

1354 lines
64KB

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