+--
+-- TABLE post-thread-user
+--
+CREATE TABLE IF NOT EXISTS `post-thread-user` (
+ `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
+ `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
+ `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item author',
+ `causer-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the contact that caused the item creation',
+ `network` char(4) NOT NULL DEFAULT '' COMMENT '',
+ `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
+ `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
+ `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',
+ `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
+ `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner id which owns this copy of the item',
+ `pinned` boolean NOT NULL DEFAULT '0' COMMENT 'The thread is pinned on the profile page',
+ `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
+ `ignored` boolean NOT NULL DEFAULT '0' COMMENT 'Ignore updates for this thread',
+ `wall` boolean NOT NULL DEFAULT '0' COMMENT 'This item was posted to the wall of uid',
+ `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
+ `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '',
+ `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
+ `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id',
+ `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen',
+ `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user',
+ `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site',
+ `psid` int unsigned COMMENT 'ID of the permission set of this post',
+ `post-user-id` int unsigned COMMENT 'Id of the post-user table',
+ PRIMARY KEY(`uid`,`uri-id`),
+ INDEX `uid_wall` (`uid`,`wall`),
+ INDEX `uid_pinned` (`uid`,`pinned`),
+ INDEX `uri-id` (`uri-id`),
+ INDEX `contact-id` (`contact-id`),
+ INDEX `psid` (`psid`),
+ INDEX `post-user-id` (`post-user-id`),
+ INDEX `owner-id` (`owner-id`),
+ INDEX `causer-id` (`causer-id`),
+ INDEX `uid_received` (`uid`,`received`),
+ INDEX `uid_commented` (`uid`,`commented`),
+ INDEX `uid_changed` (`uid`,`changed`),
+ INDEX `uid_contact-id` (`uid`,`contact-id`,`received`),
+ INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
+ INDEX `uid_network_received` (`uid`,`network`,`received`),
+ INDEX `uid_network_commented` (`uid`,`network`,`commented`),
+ INDEX `uid_contact-id_received` (`uid`,`contact-id`,`received`),
+ INDEX `author-id_received` (`author-id`,`received`),
+ INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
+ INDEX `uid_unseen_wall` (`uid`,`unseen`,`wall`),
+ INDEX `mention_uid` (`mention`,`uid`),
+ INDEX `psid_wall` (`psid`,`wall`),
+ INDEX `received` (`received`),
+ INDEX `commented` (`commented`),
+ INDEX `changed` (`changed`),
+ FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+ FOREIGN KEY (`owner-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
+ FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
+ FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
+ FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
+ FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+ FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
+ FOREIGN KEY (`post-user-id`) REFERENCES `post-user` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data per user';
+