friendica/database.sql

3072 lines
147 KiB
MySQL
Raw Normal View History

2018-02-20 13:59:37 +01:00
-- ------------------------------------------
2022-12-20 06:52:15 +01:00
-- Friendica 2023.03-dev (Giant Rhubarb)
2023-02-20 17:23:22 +01:00
-- DB_UPDATE_VERSION 1516
2018-02-20 13:59:37 +01:00
-- ------------------------------------------
2020-05-22 07:06:55 +02:00
--
-- TABLE gserver
--
CREATE TABLE IF NOT EXISTS `gserver` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
2020-05-22 07:06:55 +02:00
`version` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`site_name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`info` text COMMENT '',
`register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '',
`registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users',
`active-week-users` int unsigned COMMENT 'Number of active users in the last week',
`active-month-users` int unsigned COMMENT 'Number of active users in the last month',
`active-halfyear-users` int unsigned COMMENT 'Number of active users in the last six month',
`local-posts` int unsigned COMMENT 'Number of local posts',
`local-comments` int unsigned COMMENT 'Number of local comments',
2020-05-22 07:06:55 +02:00
`directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)',
`poco` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`noscrape` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
2020-05-22 07:06:55 +02:00
`network` char(4) NOT NULL DEFAULT '' COMMENT '',
2021-01-09 20:18:22 +01:00
`protocol` tinyint unsigned COMMENT 'The protocol of the server',
2020-05-22 07:06:55 +02:00
`platform` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`relay-subscribe` boolean NOT NULL DEFAULT '0' COMMENT 'Has the server subscribed to the relay system',
`relay-scope` varchar(10) NOT NULL DEFAULT '' COMMENT 'The scope of messages that the server wants to get',
`detection-method` tinyint unsigned COMMENT 'Method that had been used to detect that server',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`last_poco_query` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '',
2020-12-03 16:50:14 +01:00
`last_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last successful connection request',
`last_failure` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Last failed connection request',
`blocked` boolean COMMENT 'Server is blocked',
2020-07-19 12:04:50 +02:00
`failed` boolean COMMENT 'Connection failed',
2020-12-03 16:50:14 +01:00
`next_contact` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Next connection request',
2020-05-22 07:06:55 +02:00
PRIMARY KEY(`id`),
2020-12-03 16:50:14 +01:00
UNIQUE INDEX `nurl` (`nurl`(190)),
2021-02-21 17:43:06 +01:00
INDEX `next_contact` (`next_contact`),
INDEX `network` (`network`)
2020-05-22 07:06:55 +02:00
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers';
2020-11-17 23:49:55 +01:00
--
-- TABLE user
--
CREATE TABLE IF NOT EXISTS `user` (
`uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
2020-11-18 01:31:05 +01:00
`parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user',
2020-11-17 23:49:55 +01:00
`guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user',
`username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by',
`password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password',
`legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?',
`nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name',
`email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address',
`openid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone',
`language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language',
`register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration',
`login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login',
`last-activity` date COMMENT 'Day of the last activity',
2020-11-17 23:49:55 +01:00
`default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location',
`allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location',
`theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference',
`pubkey` text COMMENT 'RSA public key 4096 bit',
`prvkey` text COMMENT 'RSA private key 4096 bit',
`spubkey` text COMMENT '',
`sprvkey` text COMMENT '',
`verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email',
`blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked',
`blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
`hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers',
`blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
`unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
`cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
`notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
`page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
`account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`prvnets` boolean NOT NULL DEFAULT '0' COMMENT '',
`pwdreset` varchar(255) COMMENT 'Password reset request token',
`pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request',
`maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '',
`expire` int unsigned NOT NULL DEFAULT 0 COMMENT 'Delay in days before deleting user-related posts. Scope is controlled by pConfig.',
2020-11-17 23:49:55 +01:00
`account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed',
`account_expired` boolean NOT NULL DEFAULT '0' COMMENT '',
`account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted',
`expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration',
`def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '',
`allow_cid` mediumtext COMMENT 'default permission for this user',
`allow_gid` mediumtext COMMENT 'default permission for this user',
`deny_cid` mediumtext COMMENT 'default permission for this user',
`deny_gid` mediumtext COMMENT 'default permission for this user',
`openidserver` text COMMENT '',
PRIMARY KEY(`uid`),
INDEX `nickname` (`nickname`(32)),
INDEX `parent-uid` (`parent-uid`),
2021-02-21 14:14:17 +01:00
INDEX `guid` (`guid`),
2021-02-21 17:43:06 +01:00
INDEX `email` (`email`(64)),
2020-11-17 23:49:55 +01:00
FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users';
2021-07-08 21:16:23 +02:00
--
-- TABLE item-uri
--
CREATE TABLE IF NOT EXISTS `item-uri` (
`id` int unsigned NOT NULL auto_increment,
`uri` varbinary(383) NOT NULL COMMENT 'URI of an item',
2021-07-08 21:16:23 +02:00
`guid` varbinary(255) COMMENT 'A unique identifier for an item',
PRIMARY KEY(`id`),
UNIQUE INDEX `uri` (`uri`),
INDEX `guid` (`guid`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='URI and GUID for items';
2020-05-15 14:17:13 +02:00
--
-- TABLE contact
--
CREATE TABLE IF NOT EXISTS `contact` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`updated` datetime DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last contact update',
`network` char(4) NOT NULL DEFAULT '' COMMENT 'Network of the contact',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this contact is known by',
`nick` varchar(255) NOT NULL DEFAULT '' COMMENT 'Nick- and user name of the contact',
`location` varchar(255) DEFAULT '' COMMENT '',
`about` text COMMENT '',
`keywords` text COMMENT 'public keywords (interests) of the contact',
`xmpp` varchar(255) NOT NULL DEFAULT '' COMMENT 'XMPP address',
`matrix` varchar(255) NOT NULL DEFAULT '' COMMENT 'Matrix address',
`avatar` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`blurhash` varbinary(255) COMMENT 'BlurHash representation of the avatar',
`header` varbinary(383) COMMENT 'Header picture',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`nurl` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the contact url',
2020-05-15 14:17:13 +02:00
`addr` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`alias` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
2020-05-15 14:17:13 +02:00
`pubkey` text COMMENT 'RSA public key 4096 bit',
`prvkey` text COMMENT 'RSA private key 4096 bit',
`batch` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
`notify` varbinary(383) COMMENT '',
`poll` varbinary(383) COMMENT '',
`subscribe` varbinary(383) COMMENT '',
2020-05-15 14:17:13 +02:00
`last-update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last try to update the contact info',
`next-update` datetime COMMENT 'Next connection request',
2020-05-15 14:17:13 +02:00
`success_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful contact update',
`failure_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed update',
2020-07-19 12:04:50 +02:00
`failed` boolean COMMENT 'Connection failed',
2020-05-15 14:17:13 +02:00
`term-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`last-item` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last post',
2020-07-26 09:34:33 +02:00
`last-discovery` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'date of the last follower discovery',
`local-data` boolean COMMENT 'Is true when there are posts with this contact on the system',
2020-05-15 14:17:13 +02:00
`blocked` boolean NOT NULL DEFAULT '1' COMMENT 'Node-wide block status',
`block_reason` text COMMENT 'Node-wide block reason',
`readonly` boolean NOT NULL DEFAULT '0' COMMENT 'posts of the contact are readonly',
2021-09-13 10:22:11 +02:00
`contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
`manually-approve` boolean COMMENT 'Contact requests have to be approved manually',
2020-05-15 14:17:13 +02:00
`archive` boolean NOT NULL DEFAULT '0' COMMENT '',
`unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
`sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
`baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact',
2020-05-22 07:00:55 +02:00
`gsid` int unsigned COMMENT 'Global Server ID',
2021-09-13 10:22:11 +02:00
`bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
2020-05-15 14:17:13 +02:00
`reason` text COMMENT '',
2021-09-13 10:22:11 +02:00
`self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
`remote_self` boolean NOT NULL DEFAULT '0' COMMENT '',
`rel` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'The kind of the relation between the user and the contact',
`protocol` char(4) NOT NULL DEFAULT '' COMMENT 'Protocol of the contact',
`subhub` boolean NOT NULL DEFAULT '0' COMMENT '',
`hub-verify` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
2021-09-13 10:22:11 +02:00
`rating` tinyint NOT NULL DEFAULT 0 COMMENT 'Automatically detected feed poll frequency',
`priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Feed poll priority',
`attag` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`hidden` boolean NOT NULL DEFAULT '0' COMMENT '',
`pending` boolean NOT NULL DEFAULT '1' COMMENT 'Contact request is pending',
`deleted` boolean NOT NULL DEFAULT '0' COMMENT 'Contact has been deleted',
2020-05-15 14:17:13 +02:00
`info` mediumtext COMMENT '',
`notify_new_posts` boolean NOT NULL DEFAULT '0' COMMENT '',
`fetch_further_information` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
`ffi_keyword_denylist` text COMMENT '',
`photo` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo of the contact',
`thumb` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (thumb size)',
`micro` varbinary(383) DEFAULT '' COMMENT 'Link to the profile photo (micro size)',
2021-09-13 10:22:11 +02:00
`name-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`uri-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`avatar-date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`request` varbinary(383) COMMENT '',
`confirm` varbinary(383) COMMENT '',
`poco` varbinary(383) COMMENT '',
2021-09-13 10:22:11 +02:00
`writable` boolean NOT NULL DEFAULT '0' COMMENT '',
`forum` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a forum. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = false instead',
`prv` boolean NOT NULL DEFAULT '0' COMMENT 'contact is a private group. Deprecated, use \'contact-type\' = \'community\' and \'manually-approve\' = true instead',
`bdyear` varchar(4) NOT NULL DEFAULT '' COMMENT '',
`site-pubkey` text COMMENT 'Deprecated',
`gender` varchar(32) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`duplex` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`issued-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
`dfrn-id` varbinary(383) NOT NULL DEFAULT '' COMMENT 'Deprecated',
2021-09-13 10:22:11 +02:00
`aes_allow` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`ret-aes` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`usehub` boolean NOT NULL DEFAULT '0' COMMENT 'Deprecated',
`closeness` tinyint unsigned NOT NULL DEFAULT 99 COMMENT 'Deprecated',
`profile-id` int unsigned COMMENT 'Deprecated',
2020-05-15 14:17:13 +02:00
PRIMARY KEY(`id`),
INDEX `uid_name` (`uid`,`name`(190)),
INDEX `self_uid` (`self`,`uid`),
2020-11-19 10:47:59 +01:00
INDEX `alias_uid` (`alias`(128),`uid`),
2020-05-15 14:17:13 +02:00
INDEX `pending_uid` (`pending`,`uid`),
INDEX `blocked_uid` (`blocked`,`uid`),
INDEX `uid_rel_network_poll` (`uid`,`rel`,`network`,`poll`(64),`archive`),
INDEX `uid_network_batch` (`uid`,`network`,`batch`(64)),
INDEX `batch_contact-type` (`batch`(64),`contact-type`),
2020-11-19 10:47:59 +01:00
INDEX `addr_uid` (`addr`(128),`uid`),
INDEX `nurl_uid` (`nurl`(128),`uid`),
INDEX `nick_uid` (`nick`(128),`uid`),
INDEX `attag_uid` (`attag`(96),`uid`),
2020-07-19 12:04:50 +02:00
INDEX `network_uid_lastupdate` (`network`,`uid`,`last-update`),
INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
INDEX `next-update` (`next-update`),
INDEX `local-data-next-update` (`local-data`,`next-update`),
2020-07-31 19:58:25 +02:00
INDEX `uid_lastitem` (`uid`,`last-item`),
2021-02-21 17:43:06 +01:00
INDEX `baseurl` (`baseurl`(64)),
INDEX `uid_contact-type` (`uid`,`contact-type`),
INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
INDEX `self_network_uid` (`self`,`network`,`uid`),
2022-08-15 15:23:01 +02:00
INDEX `gsid_uid_failed` (`gsid`,`uid`,`failed`),
INDEX `uri-id` (`uri-id`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
2020-05-22 07:00:55 +02:00
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
2020-05-15 14:17:13 +02:00
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table';
2020-08-24 22:09:03 +02:00
--
-- TABLE tag
--
CREATE TABLE IF NOT EXISTS `tag` (
`id` int unsigned NOT NULL auto_increment COMMENT '',
`name` varchar(96) NOT NULL DEFAULT '' COMMENT '',
`url` varbinary(383) NOT NULL DEFAULT '' COMMENT '',
2022-04-24 02:20:06 +02:00
`type` tinyint unsigned COMMENT 'Type of the tag (Unknown, General Collection, Follower Collection or Account)',
2020-08-24 22:09:03 +02:00
PRIMARY KEY(`id`),
UNIQUE INDEX `type_name_url` (`name`,`url`),
INDEX `url` (`url`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions';
2020-05-15 14:17:13 +02:00
--
-- TABLE permissionset
--
CREATE TABLE IF NOT EXISTS `permissionset` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id of this permission set',
`allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>\'',
`allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
`deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
`deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
PRIMARY KEY(`id`),
INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
2020-05-15 14:17:13 +02:00
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
2020-11-20 01:17:32 +01:00
--
-- TABLE verb
--
CREATE TABLE IF NOT EXISTS `verb` (
`id` smallint unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL DEFAULT '' COMMENT '',
2021-02-21 14:14:17 +01:00
PRIMARY KEY(`id`),
INDEX `name` (`name`)
2020-11-20 01:17:32 +01:00
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Activity Verbs';
--
-- TABLE 2fa_app_specific_password
--
CREATE TABLE IF NOT EXISTS `2fa_app_specific_password` (
`id` mediumint unsigned NOT NULL auto_increment COMMENT 'Password ID for revocation',
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
`description` varchar(255) COMMENT 'Description of the usage of the password',
`hashed_password` varchar(255) NOT NULL COMMENT 'Hashed password',
`generated` datetime NOT NULL COMMENT 'Datetime the password was generated',
`last_used` datetime COMMENT 'Datetime the password was last used',
PRIMARY KEY(`id`),
2020-08-24 22:09:03 +02:00
INDEX `uid_description` (`uid`,`description`(190)),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor app-specific _password';
--
-- TABLE 2fa_recovery_codes
--
CREATE TABLE IF NOT EXISTS `2fa_recovery_codes` (
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
`code` varchar(50) NOT NULL COMMENT 'Recovery code string',
`generated` datetime NOT NULL COMMENT 'Datetime the code was generated',
`used` datetime COMMENT 'Datetime the code was used',
2021-01-30 23:43:50 +01:00
PRIMARY KEY(`uid`,`code`),
2020-08-24 22:09:03 +02:00
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication recovery codes';
--
-- TABLE 2fa_trusted_browser
--
CREATE TABLE IF NOT EXISTS `2fa_trusted_browser` (
2021-01-30 23:43:50 +01:00
`cookie_hash` varchar(80) NOT NULL COMMENT 'Trusted cookie hash',
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
`user_agent` text COMMENT 'User agent string',
2022-06-25 14:45:33 +02:00
`trusted` boolean NOT NULL DEFAULT '1' COMMENT 'Whenever this browser should be trusted or not',
2021-01-30 23:43:50 +01:00
`created` datetime NOT NULL COMMENT 'Datetime the trusted browser was recorded',
`last_used` datetime COMMENT 'Datetime the trusted browser was last used',
PRIMARY KEY(`cookie_hash`),
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Two-factor authentication trusted browsers';
2022-11-30 06:59:27 +01:00
--
-- TABLE account-suggestion
--
CREATE TABLE IF NOT EXISTS `account-suggestion` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
`level` smallint unsigned COMMENT 'level of closeness',
`ignore` boolean NOT NULL DEFAULT '0' COMMENT 'If set, this account will not be suggested again',
PRIMARY KEY(`uid`,`uri-id`),
INDEX `uri-id_uid` (`uri-id`,`uid`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Account suggestion';
2022-09-16 07:00:06 +02:00
--
-- TABLE account-user
--
CREATE TABLE IF NOT EXISTS `account-user` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the account url',
`uid` mediumint unsigned NOT NULL COMMENT 'User ID',
PRIMARY KEY(`id`),
UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),
INDEX `uid_uri-id` (`uid`,`uri-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Remote and local accounts';
2018-10-07 22:36:15 +02:00
--
-- TABLE apcontact
--
CREATE TABLE IF NOT EXISTS `apcontact` (
`url` varbinary(383) NOT NULL COMMENT 'URL of the contact',
`uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the apcontact url',
`uuid` varbinary(255) COMMENT '',
2018-10-07 22:36:15 +02:00
`type` varchar(20) NOT NULL COMMENT '',
`following` varbinary(383) COMMENT '',
`followers` varbinary(383) COMMENT '',
`inbox` varbinary(383) NOT NULL COMMENT '',
`outbox` varbinary(383) COMMENT '',
`sharedinbox` varbinary(383) COMMENT '',
`featured` varbinary(383) COMMENT 'Address for the collection of featured posts',
`featured-tags` varbinary(383) COMMENT 'Address for the collection of featured tags',
`manually-approve` boolean COMMENT '',
2021-06-30 07:40:11 +02:00
`discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory',
`suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended',
2018-10-07 22:36:15 +02:00
`nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`name` varchar(255) COMMENT '',
`about` text COMMENT '',
`xmpp` varchar(255) COMMENT 'XMPP address',
`matrix` varchar(255) COMMENT 'Matrix address',
`photo` varbinary(383) COMMENT '',
`header` varbinary(383) COMMENT 'Header picture',
2018-10-07 22:36:15 +02:00
`addr` varchar(255) COMMENT '',
`alias` varbinary(383) COMMENT '',
2018-10-07 22:36:15 +02:00
`pubkey` text COMMENT '',
`subscribe` varbinary(383) COMMENT '',
`baseurl` varbinary(383) COMMENT 'baseurl of the ap contact',
2020-05-22 07:00:55 +02:00
`gsid` int unsigned COMMENT 'Global Server ID',
`generator` varchar(255) COMMENT 'Name of the contact\'s system',
`following_count` int unsigned DEFAULT 0 COMMENT 'Number of following contacts',
`followers_count` int unsigned DEFAULT 0 COMMENT 'Number of followers',
`statuses_count` int unsigned DEFAULT 0 COMMENT 'Number of posts',
2018-10-07 22:36:15 +02:00
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
PRIMARY KEY(`url`),
INDEX `addr` (`addr`(32)),
2018-11-16 21:21:33 +01:00
INDEX `alias` (`alias`(190)),
2020-05-22 07:00:55 +02:00
INDEX `followers` (`followers`(190)),
2020-07-19 12:04:50 +02:00
INDEX `baseurl` (`baseurl`(190)),
2020-11-24 07:26:26 +01:00
INDEX `sharedinbox` (`sharedinbox`(190)),
2020-05-22 07:00:55 +02:00
INDEX `gsid` (`gsid`),
UNIQUE INDEX `uri-id` (`uri-id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
2020-05-22 07:00:55 +02:00
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
2018-10-07 22:36:15 +02:00
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='ActivityPub compatible contacts - used in the ActivityPub implementation';
--
-- TABLE application
--
CREATE TABLE IF NOT EXISTS `application` (
`id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
`client_id` varchar(64) NOT NULL COMMENT '',
`client_secret` varchar(64) NOT NULL COMMENT '',
`name` varchar(255) NOT NULL COMMENT '',
`redirect_uri` varbinary(383) NOT NULL COMMENT '',
`website` varbinary(383) COMMENT '',
`scopes` varchar(255) COMMENT '',
`read` boolean COMMENT 'Read scope',
`write` boolean COMMENT 'Write scope',
`follow` boolean COMMENT 'Follow scope',
2021-05-16 09:37:11 +02:00
`push` boolean COMMENT 'Push scope',
PRIMARY KEY(`id`),
UNIQUE INDEX `client_id` (`client_id`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth application';
2022-06-06 23:38:59 +02:00
--
-- TABLE application-marker
--
CREATE TABLE IF NOT EXISTS `application-marker` (
`application-id` int unsigned NOT NULL COMMENT '',
`uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
`timeline` varchar(64) NOT NULL COMMENT 'Marker (home, notifications)',
`last_read_id` varbinary(383) COMMENT 'Marker id for the timeline',
2022-06-06 23:38:59 +02:00
`version` smallint unsigned COMMENT 'Version number',
`updated_at` datetime COMMENT 'creation time',
PRIMARY KEY(`application-id`,`uid`,`timeline`),
INDEX `uid_id` (`uid`),
FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Timeline marker';
2021-05-11 08:19:23 +02:00
--
-- TABLE application-token
--
CREATE TABLE IF NOT EXISTS `application-token` (
`application-id` int unsigned NOT NULL COMMENT '',
`uid` mediumint unsigned NOT NULL COMMENT 'Owner User id',
`code` varchar(64) NOT NULL COMMENT '',
`access_token` varchar(64) NOT NULL COMMENT '',
`created_at` datetime NOT NULL COMMENT 'creation time',
`scopes` varchar(255) COMMENT '',
`read` boolean COMMENT 'Read scope',
`write` boolean COMMENT 'Write scope',
`follow` boolean COMMENT 'Follow scope',
2021-05-16 09:37:11 +02:00
`push` boolean COMMENT 'Push scope',
2021-05-11 08:19:23 +02:00
PRIMARY KEY(`application-id`,`uid`),
INDEX `uid_id` (`uid`,`application-id`),
FOREIGN KEY (`application-id`) REFERENCES `application` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='OAuth user token';
2018-02-20 13:59:37 +01:00
--
-- TABLE attach
--
CREATE TABLE IF NOT EXISTS `attach` (
2018-05-29 16:11:25 +02:00
`id` int unsigned NOT NULL auto_increment COMMENT 'generated index',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`hash` varchar(64) NOT NULL DEFAULT '' COMMENT 'hash',
`filename` varchar(255) NOT NULL DEFAULT '' COMMENT 'filename of original',
`filetype` varchar(64) NOT NULL DEFAULT '' COMMENT 'mimetype',
`filesize` int unsigned NOT NULL DEFAULT 0 COMMENT 'size in bytes',
`data` longblob NOT NULL COMMENT 'file data',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation time',
`edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'last edit time',
`allow_cid` mediumtext COMMENT 'Access Control - list of allowed contact.id \'<19><78>',
`allow_gid` mediumtext COMMENT 'Access Control - list of allowed groups',
`deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id',
`deny_gid` mediumtext COMMENT 'Access Control - list of denied groups',
2019-01-03 22:51:36 +01:00
`backend-class` tinytext COMMENT 'Storage backend class',
`backend-ref` text COMMENT 'Storage backend data reference',
2020-08-24 22:09:03 +02:00
PRIMARY KEY(`id`),
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='file attachments';
2018-02-20 13:59:37 +01:00
--
-- TABLE cache
--
CREATE TABLE IF NOT EXISTS `cache` (
2018-03-01 05:48:28 +01:00
`k` varbinary(255) NOT NULL COMMENT 'cache key',
`v` mediumtext COMMENT 'cached serialized value',
`expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache expiration',
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of cache insertion',
PRIMARY KEY(`k`),
INDEX `k_expires` (`k`,`expires`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Stores temporary data';
2018-02-20 13:59:37 +01:00
2023-02-04 20:52:24 +01:00
--
-- TABLE config
--
CREATE TABLE IF NOT EXISTS `config` (
`id` int unsigned NOT NULL auto_increment COMMENT '',
2023-02-04 20:52:24 +01:00
`cat` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The category of the entry',
`k` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The key of the entry',
`v` mediumtext COMMENT '',
PRIMARY KEY(`id`),
UNIQUE INDEX `cat_k` (`cat`,`k`)
2023-02-04 20:52:24 +01:00
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
2020-03-10 23:04:03 +01:00
--
-- TABLE contact-relation
--
CREATE TABLE IF NOT EXISTS `contact-relation` (
`cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact the related contact had interacted with',
`relation-cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'related contact who had interacted with the contact',
`last-interaction` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last interaction',
2020-07-26 09:34:33 +02:00
`follow-updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last update of the contact relationship',
`follows` boolean NOT NULL DEFAULT '0' COMMENT '',
2020-03-10 23:04:03 +01:00
PRIMARY KEY(`cid`,`relation-cid`),
2020-07-26 09:34:33 +02:00
INDEX `relation-cid` (`relation-cid`),
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`relation-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
2020-03-10 23:04:03 +01:00
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Contact relations';
2018-02-20 13:59:37 +01:00
--
-- TABLE conv
--
CREATE TABLE IF NOT EXISTS `conv` (
2018-05-29 16:11:25 +02:00
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`guid` varbinary(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this conversation',
2018-05-29 16:11:25 +02:00
`recips` text COMMENT 'sender_handle;recipient_handle',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`creator` varchar(255) NOT NULL DEFAULT '' COMMENT 'handle of creator',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'creation timestamp',
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'edited timestamp',
`subject` text COMMENT 'subject of initial message',
2018-02-20 13:59:37 +01:00
PRIMARY KEY(`id`),
2020-08-24 22:09:03 +02:00
INDEX `uid` (`uid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='private messages';
2018-02-20 13:59:37 +01:00
2021-07-29 00:22:00 +02:00
--
-- TABLE workerqueue
--
CREATE TABLE IF NOT EXISTS `workerqueue` (
`id` int unsigned NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
`command` varchar(100) COMMENT 'Task command',
`parameter` mediumtext COMMENT 'Task parameter',
`priority` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Task priority',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
`pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
`executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
`next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
`retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
`done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
PRIMARY KEY(`id`),
INDEX `command` (`command`),
INDEX `done_command_parameter` (`done`,`command`,`parameter`(64)),
INDEX `done_executed` (`done`,`executed`),
INDEX `done_priority_retrial_created` (`done`,`priority`,`retrial`,`created`),
INDEX `done_priority_next_try` (`done`,`priority`,`next_try`),
INDEX `done_pid_next_try` (`done`,`pid`,`next_try`),
INDEX `done_pid_retrial` (`done`,`pid`,`retrial`),
INDEX `done_pid_priority_created` (`done`,`pid`,`priority`,`created`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
2020-12-01 23:21:44 +01:00
--
-- TABLE delayed-post
--
CREATE TABLE IF NOT EXISTS `delayed-post` (
`id` int unsigned NOT NULL auto_increment,
`uri` varbinary(383) COMMENT 'URI of the post that will be distributed later',
2020-12-01 23:21:44 +01:00
`uid` mediumint unsigned COMMENT 'Owner User id',
`delayed` datetime COMMENT 'delay time',
2021-07-29 12:34:31 +02:00
`wid` int unsigned COMMENT 'Workerqueue id',
2020-12-01 23:21:44 +01:00
PRIMARY KEY(`id`),
2020-12-02 01:34:10 +01:00
UNIQUE INDEX `uid_uri` (`uid`,`uri`(190)),
2021-07-29 00:22:00 +02:00
INDEX `wid` (`wid`),
2021-07-29 12:34:31 +02:00
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
2020-12-02 15:55:57 +01:00
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
2020-12-01 23:21:44 +01:00
2022-12-31 13:19:34 +01:00
--
-- TABLE delivery-queue
--
CREATE TABLE IF NOT EXISTS `delivery-queue` (
2022-12-31 17:20:18 +01:00
`gsid` int unsigned NOT NULL COMMENT 'Target server',
`uri-id` int unsigned NOT NULL COMMENT 'Delivered post',
2022-12-31 13:19:34 +01:00
`created` datetime COMMENT '',
`command` varbinary(32) COMMENT '',
2022-12-31 17:20:18 +01:00
`cid` int unsigned COMMENT 'Target contact',
2022-12-31 13:19:34 +01:00
`uid` mediumint unsigned COMMENT 'Delivering user',
`failed` tinyint DEFAULT 0 COMMENT 'Number of times the delivery has failed',
PRIMARY KEY(`uri-id`,`gsid`),
INDEX `gsid_created` (`gsid`,`created`),
INDEX `uid` (`uid`),
INDEX `cid` (`cid`),
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for posts for the batch processing';
--
-- TABLE diaspora-contact
--
CREATE TABLE IF NOT EXISTS `diaspora-contact` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
`addr` varchar(255) COMMENT '',
`alias` varchar(255) COMMENT '',
`nick` varchar(255) COMMENT '',
`name` varchar(255) COMMENT '',
`given-name` varchar(255) COMMENT '',
`family-name` varchar(255) COMMENT '',
`photo` varchar(255) COMMENT '',
`photo-medium` varchar(255) COMMENT '',
`photo-small` varchar(255) COMMENT '',
`batch` varchar(255) COMMENT '',
`notify` varchar(255) COMMENT '',
`poll` varchar(255) COMMENT '',
`subscribe` varchar(255) COMMENT '',
`searchable` boolean COMMENT '',
`pubkey` text COMMENT '',
`gsid` int unsigned COMMENT 'Global Server ID',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
</