diff --git a/database.sql b/database.sql index 7a8ee0adb7..58d79fb4bb 100644 --- a/database.sql +++ b/database.sql @@ -712,13 +712,16 @@ CREATE TABLE IF NOT EXISTS `hook` ( -- CREATE TABLE IF NOT EXISTS `inbox-status` ( `url` varbinary(255) NOT NULL COMMENT 'URL of the inbox', + `uri-id` int unsigned COMMENT 'Item-uri id of inbox url', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date of this entry', `success` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last successful delivery', `failure` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of the last failed delivery', `previous` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Previous delivery date', `archive` boolean NOT NULL DEFAULT '0' COMMENT 'Is the inbox archived?', `shared` boolean NOT NULL DEFAULT '0' COMMENT 'Is it a shared inbox?', - PRIMARY KEY(`url`) + PRIMARY KEY(`url`), + INDEX `uri-id` (`uri-id`), + FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Status of ActivityPub inboxes'; -- @@ -1114,6 +1117,23 @@ CREATE TABLE IF NOT EXISTS `post-content` ( FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Content for all posts'; +-- +-- TABLE post-delivery +-- +CREATE TABLE IF NOT EXISTS `post-delivery` ( + `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri', + `inbox-id` int unsigned NOT NULL COMMENT 'Item-uri id of inbox url', + `uid` mediumint unsigned COMMENT 'Delivering user', + `created` datetime DEFAULT '0001-01-01 00:00:00' COMMENT '', + `command` varbinary(32) COMMENT '', + PRIMARY KEY(`uri-id`,`inbox-id`), + INDEX `inbox-id_created` (`inbox-id`,`created`), + INDEX `uid` (`uid`), + FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, + FOREIGN KEY (`inbox-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='Status of ActivityPub inboxes'; + -- -- TABLE post-delivery-data -- diff --git a/doc/database.md b/doc/database.md index dff31657fd..961e8183ab 100644 --- a/doc/database.md +++ b/doc/database.md @@ -50,6 +50,7 @@ Database Tables | [post-category](help/database/db_post-category) | post relation to categories | | [post-collection](help/database/db_post-collection) | Collection of posts | | [post-content](help/database/db_post-content) | Content for all posts | +| [post-delivery](help/database/db_post-delivery) | Status of ActivityPub inboxes | | [post-delivery-data](help/database/db_post-delivery-data) | Delivery data for items | | [post-link](help/database/db_post-link) | Post related external links | | [post-media](help/database/db_post-media) | Attached media | diff --git a/doc/database/db_inbox-status.md b/doc/database/db_inbox-status.md index 3b82cf46a0..79df149a59 100644 --- a/doc/database/db_inbox-status.md +++ b/doc/database/db_inbox-status.md @@ -9,6 +9,7 @@ Fields | Field | Description | Type | Null | Key | Default | Extra | | -------- | ------------------------------------ | -------------- | ---- | --- | ------------------- | ----- | | url | URL of the inbox | varbinary(255) | NO | PRI | NULL | | +| uri-id | Item-uri id of inbox url | int unsigned | YES | | NULL | | | created | Creation date of this entry | datetime | NO | | 0001-01-01 00:00:00 | | | success | Date of the last successful delivery | datetime | NO | | 0001-01-01 00:00:00 | | | failure | Date of the last failed delivery | datetime | NO | | 0001-01-01 00:00:00 | | @@ -22,6 +23,13 @@ Indexes | Name | Fields | | ------- | ------ | | PRIMARY | url | +| uri-id | uri-id | +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uri-id | [item-uri](help/database/db_item-uri) | id | Return to [database documentation](help/database) diff --git a/doc/database/db_post-delivery.md b/doc/database/db_post-delivery.md new file mode 100644 index 0000000000..1937e059a5 --- /dev/null +++ b/doc/database/db_post-delivery.md @@ -0,0 +1,35 @@ +Table post-delivery +=========== + +Status of ActivityPub inboxes + +Fields +------ + +| Field | Description | Type | Null | Key | Default | Extra | +| -------- | --------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | ----- | +| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | | +| inbox-id | Item-uri id of inbox url | int unsigned | NO | PRI | NULL | | +| uid | Delivering user | mediumint unsigned | YES | | NULL | | +| created | | datetime | YES | | 0001-01-01 00:00:00 | | +| command | | varbinary(32) | YES | | NULL | | + +Indexes +------------ + +| Name | Fields | +| ---------------- | ----------------- | +| PRIMARY | uri-id, inbox-id | +| inbox-id_created | inbox-id, created | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uri-id | [item-uri](help/database/db_item-uri) | id | +| inbox-id | [item-uri](help/database/db_item-uri) | id | +| uid | [user](help/database/db_user) | uid | + +Return to [database documentation](help/database)