forgotten $
[friendica.git/.git] / database.sql
index 78632bb..60d4b1c 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 2018.08-dev (The Tazmans Flax-lily)
--- DB_UPDATE_VERSION 1277
+-- DB_UPDATE_VERSION 1283
 -- ------------------------------------------
 
 
@@ -208,7 +208,7 @@ CREATE TABLE IF NOT EXISTS `conv` (
 -- TABLE conversation
 --
 CREATE TABLE IF NOT EXISTS `conversation` (
-       `item-uri` varbinary(255) NOT NULL COMMENT 'URI of the item',
+       `item-uri` varbinary(255) NOT NULL COMMENT 'Original URI of the item - unrelated to the table with the same name',
        `reply-to-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'URI to which this item is a reply',
        `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI',
        `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link',
@@ -455,10 +455,13 @@ CREATE TABLE IF NOT EXISTS `item` (
        `id` int unsigned NOT NULL auto_increment,
        `guid` varchar(255) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this item',
        `uri` varchar(255) NOT NULL DEFAULT '' COMMENT '',
+       `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
        `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
        `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',
        `parent-uri` varchar(255) NOT NULL DEFAULT '' COMMENT 'uri of the parent to this item',
+       `parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
        `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',
+       `thr-parent-id` int unsigned COMMENT 'Id of the item-uri table that contains the thread parent 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)',
        `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item',
@@ -471,9 +474,9 @@ CREATE TABLE IF NOT EXISTS `item` (
        `icid` int unsigned COMMENT 'Id of the item-content table entry that contains the whole item content',
        `iaid` int unsigned COMMENT 'Id of the item-activity table entry that contains the activity data',
        `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '',
+       `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
        `global` boolean NOT NULL DEFAULT '0' COMMENT '',
        `private` boolean NOT NULL DEFAULT '0' COMMENT 'distribution is restricted',
-       `bookmark` boolean NOT NULL DEFAULT '0' COMMENT 'item has been bookmarked',
        `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
        `moderated` boolean NOT NULL DEFAULT '0' COMMENT '',
        `deleted` boolean NOT NULL DEFAULT '0' COMMENT 'item has been deleted',
@@ -486,16 +489,18 @@ CREATE TABLE IF NOT EXISTS `item` (
        `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen',
        `mention` boolean NOT NULL DEFAULT '0' COMMENT 'The owner of this item was mentioned in it',
        `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
-       `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',
-       `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',
-       `inform` mediumtext COMMENT 'Additional receivers of this post',
+       `psid` int unsigned COMMENT 'ID of the permission set of this post',
        `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',
        `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id',
        `attach` mediumtext COMMENT 'JSON structure representing attachments to this item',
-       `type` varchar(20) NOT NULL DEFAULT '' COMMENT '',
+       `allow_cid` mediumtext COMMENT 'Deprecated',
+       `allow_gid` mediumtext COMMENT 'Deprecated',
+       `deny_cid` mediumtext COMMENT 'Deprecated',
+       `deny_gid` mediumtext COMMENT 'Deprecated',
+       `postopts` text COMMENT 'Deprecated',
+       `inform` mediumtext COMMENT 'Deprecated',
+       `type` varchar(20) COMMENT 'Deprecated',
+       `bookmark` boolean COMMENT 'Deprecated',
        `file` mediumtext COMMENT 'Deprecated',
        `location` varchar(255) COMMENT 'Deprecated',
        `coord` varchar(255) COMMENT 'Deprecated',
@@ -542,7 +547,8 @@ CREATE TABLE IF NOT EXISTS `item` (
         INDEX `uid_wall_changed` (`uid`,`wall`,`changed`),
         INDEX `uid_eventid` (`uid`,`event-id`),
         INDEX `icid` (`icid`),
-        INDEX `iaid` (`iaid`)
+        INDEX `iaid` (`iaid`),
+        INDEX `psid_wall` (`psid`,`wall`)
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts';
 
 --
@@ -551,6 +557,7 @@ CREATE TABLE IF NOT EXISTS `item` (
 CREATE TABLE IF NOT EXISTS `item-activity` (
        `id` int unsigned NOT NULL auto_increment,
        `uri` varchar(255) COMMENT '',
+       `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
        `uri-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
        `activity` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
         PRIMARY KEY(`id`),
@@ -564,6 +571,7 @@ CREATE TABLE IF NOT EXISTS `item-activity` (
 CREATE TABLE IF NOT EXISTS `item-content` (
        `id` int unsigned NOT NULL auto_increment,
        `uri` varchar(255) COMMENT '',
+       `uri-id` int unsigned COMMENT 'Id of the item-uri table entry that contains the item uri',
        `uri-plink-hash` varchar(80) NOT NULL DEFAULT '' COMMENT 'RIPEMD-128 hash from uri',
        `title` varchar(255) NOT NULL DEFAULT '' COMMENT 'item title',
        `content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
@@ -585,6 +593,28 @@ CREATE TABLE IF NOT EXISTS `item-content` (
         INDEX `uri` (`uri`(191))
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts';
 
+--
+-- TABLE item-delivery-data
+--
+CREATE TABLE IF NOT EXISTS `item-delivery-data` (
+       `iid` int unsigned NOT NULL COMMENT 'Item id',
+       `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',
+       `inform` mediumtext COMMENT 'Additional receivers of the linked item',
+        PRIMARY KEY(`iid`)
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
+
+--
+-- TABLE item-uri
+--
+CREATE TABLE IF NOT EXISTS `item-uri` (
+       `id` int unsigned NOT NULL auto_increment,
+       `uri` varbinary(255) NOT NULL COMMENT 'URI of an item',
+       `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';
+
 --
 -- TABLE locks
 --
@@ -760,6 +790,20 @@ CREATE TABLE IF NOT EXISTS `pconfig` (
         UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='personal (per user) configuration storage';
 
+--
+-- 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` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30))
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='';
+
 --
 -- TABLE photo
 --
@@ -1031,13 +1075,14 @@ CREATE TABLE IF NOT EXISTS `thread` (
        `visible` boolean NOT NULL DEFAULT '0' COMMENT '',
        `starred` boolean NOT NULL DEFAULT '0' COMMENT '',
        `ignored` boolean NOT NULL DEFAULT '0' COMMENT '',
-       `bookmark` boolean NOT NULL DEFAULT '0' COMMENT '',
+       `post-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Post type (personal note, bookmark, ...)',
        `unseen` boolean NOT NULL DEFAULT '1' COMMENT '',
        `deleted` boolean NOT NULL DEFAULT '0' COMMENT '',
        `origin` boolean NOT NULL DEFAULT '0' COMMENT '',
        `forum_mode` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
        `mention` boolean NOT NULL DEFAULT '0' COMMENT '',
        `network` char(4) NOT NULL DEFAULT '' COMMENT '',
+       `bookmark` boolean COMMENT '',
         PRIMARY KEY(`iid`),
         INDEX `uid_network_commented` (`uid`,`network`,`commented`),
         INDEX `uid_network_created` (`uid`,`network`,`created`),
@@ -1128,6 +1173,18 @@ CREATE TABLE IF NOT EXISTS `userd` (
         INDEX `username` (`username`(32))
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Deleted usernames';
 
+--
+-- TABLE user-contact
+--
+CREATE TABLE IF NOT EXISTS `user-contact` (
+       `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Contact id of the linked public contact',
+       `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
+       `blocked` boolean COMMENT 'Contact is completely blocked for this user',
+       `ignored` boolean COMMENT 'Posts from this contact are ignored',
+       `collapsed` boolean COMMENT 'Posts from this contact are collapsed',
+        PRIMARY KEY(`uid`,`cid`)
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific public contact data';
+
 --
 -- TABLE user-item
 --
@@ -1135,6 +1192,7 @@ CREATE TABLE IF NOT EXISTS `user-item` (
        `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
        `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
        `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
+       `ignored` boolean COMMENT 'Ignore this thread if set',
         PRIMARY KEY(`uid`,`iid`)
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';