+--
+-- TABLE post
+--
+CREATE TABLE IF NOT EXISTS `post` (
+ `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
+ `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
+ `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent uri',
+ `external-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the external uri',
+ `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.',
+ `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)',
+ `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime',
+ `gravity` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
+ `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from',
+ `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the owner of this item',
+ `author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
+ `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',
+ `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
+ `vid` smallint unsigned COMMENT 'Id of the verb table entry that contains the activity verbs',
+ `private` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '0=public, 1=private, 2=unlisted',
+ `global` boolean NOT NULL DEFAULT '0' COMMENT '',
+ `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
+ `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been marked for deletion',
+ PRIMARY KEY(`uri-id`),
+ INDEX `parent-uri-id` (`parent-uri-id`),
+ INDEX `thr-parent-id` (`thr-parent-id`),
+ INDEX `external-id` (`external-id`),
+ INDEX `owner-id` (`owner-id`),
+ INDEX `author-id` (`author-id`),
+ INDEX `causer-id` (`causer-id`),
+ INDEX `vid` (`vid`),
+ INDEX `received` (`received`),
+ FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+ FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+ FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
+ FOREIGN KEY (`external-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 (`vid`) REFERENCES `verb` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
+