From 5d9ce800076f69b0de5c1d1d18b2e5a87de772ad Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 12 Nov 2022 16:50:28 -0500 Subject: [PATCH] [Database version 1489] Add new report database tables --- database.sql | 31 +++++++++++++++++++++++++++++- doc/database.md | 2 ++ doc/database/db_report-post.md | 30 +++++++++++++++++++++++++++++ doc/database/db_report.md | 35 ++++++++++++++++++++++++++++++++++ static/dbstructure.config.php | 29 +++++++++++++++++++++++++++- 5 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 doc/database/db_report-post.md create mode 100644 doc/database/db_report.md diff --git a/database.sql b/database.sql index 9f96b7bbf3..71a5f0ae5f 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2022.12-dev (Giant Rhubarb) --- DB_UPDATE_VERSION 1488 +-- DB_UPDATE_VERSION 1489 -- ------------------------------------------ @@ -1646,6 +1646,35 @@ CREATE TABLE IF NOT EXISTS `register` ( FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='registrations requiring admin approval'; +-- +-- TABLE report +-- +CREATE TABLE IF NOT EXISTS `report` ( + `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID', + `uid` mediumint unsigned NOT NULL COMMENT 'Reporting user', + `cid` int unsigned NOT NULL COMMENT 'Reported contact', + `comment` text COMMENT 'Report', + `forward` boolean COMMENT 'Forward the report to the remote server', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '', + PRIMARY KEY(`id`), + INDEX `uid` (`uid`), + INDEX `cid` (`cid`), + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE, + FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE +) DEFAULT COLLATE utf8mb4_general_ci COMMENT=''; + +-- +-- TABLE report-post +-- +CREATE TABLE IF NOT EXISTS `report-post` ( + `rid` int unsigned NOT NULL COMMENT 'Report id', + `uri-id` int unsigned NOT NULL COMMENT 'Uri-id of the reported post', + PRIMARY KEY(`rid`,`uri-id`), + INDEX `uri-id` (`uri-id`), + FOREIGN KEY (`rid`) REFERENCES `report` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, + FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE +) DEFAULT COLLATE utf8mb4_general_ci COMMENT=''; + -- -- TABLE search -- diff --git a/doc/database.md b/doc/database.md index 1ffbf91f5d..4259749d2a 100644 --- a/doc/database.md +++ b/doc/database.md @@ -74,6 +74,8 @@ Database Tables | [profile_field](help/database/db_profile_field) | Custom profile fields | | [push_subscriber](help/database/db_push_subscriber) | Used for OStatus: Contains feed subscribers | | [register](help/database/db_register) | registrations requiring admin approval | +| [report](help/database/db_report) | | +| [report-post](help/database/db_report-post) | | | [search](help/database/db_search) | | | [session](help/database/db_session) | web session storage | | [storage](help/database/db_storage) | Data stored by Database storage backend | diff --git a/doc/database/db_report-post.md b/doc/database/db_report-post.md new file mode 100644 index 0000000000..303aa3256f --- /dev/null +++ b/doc/database/db_report-post.md @@ -0,0 +1,30 @@ +Table report-post +=========== + + + +Fields +------ + +| Field | Description | Type | Null | Key | Default | Extra | +| ------ | --------------------------- | ------------ | ---- | --- | ------- | ----- | +| rid | Report id | int unsigned | NO | PRI | NULL | | +| uri-id | Uri-id of the reported post | int unsigned | NO | PRI | NULL | | + +Indexes +------------ + +| Name | Fields | +| ------- | ----------- | +| PRIMARY | rid, uri-id | +| uri-id | uri-id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| rid | [report](help/database/db_report) | id | +| uri-id | [item-uri](help/database/db_item-uri) | id | + +Return to [database documentation](help/database) diff --git a/doc/database/db_report.md b/doc/database/db_report.md new file mode 100644 index 0000000000..6e52636eb3 --- /dev/null +++ b/doc/database/db_report.md @@ -0,0 +1,35 @@ +Table report +=========== + + + +Fields +------ + +| Field | Description | Type | Null | Key | Default | Extra | +| ------- | --------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | +| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | +| uid | Reporting user | mediumint unsigned | NO | | NULL | | +| cid | Reported contact | int unsigned | NO | | NULL | | +| comment | Report | text | YES | | NULL | | +| forward | Forward the report to the remote server | boolean | YES | | NULL | | +| created | | datetime | NO | | 0001-01-01 00:00:00 | | + +Indexes +------------ + +| Name | Fields | +| ------- | ------ | +| PRIMARY | id | +| uid | uid | +| cid | cid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | +| cid | [contact](help/database/db_contact) | id | + +Return to [database documentation](help/database) diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 343cf30206..17064fd959 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -55,7 +55,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1488); + define('DB_UPDATE_VERSION', 1489); } return [ @@ -1649,6 +1649,33 @@ return [ "uid" => ["uid"], ] ], + "report" => [ + "comment" => "", + "fields" => [ + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "foreign" => ["user" => "uid"], "comment" => "Reporting user"], + "cid" => ["type" => "int unsigned", "not null" => "1", "foreign" => ["contact" => "id"], "comment" => "Reported contact"], + "comment" => ["type" => "text", "comment" => "Report"], + "forward" => ["type" => "boolean", "comment" => "Forward the report to the remote server"], + "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""], + ], + "indexes" => [ + "PRIMARY" => ["id"], + "uid" => ["uid"], + "cid" => ["cid"], + ] + ], + "report-post" => [ + "comment" => "", + "fields" => [ + "rid" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["report" => "id"], "comment" => "Report id"], + "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Uri-id of the reported post"], + ], + "indexes" => [ + "PRIMARY" => ["rid", "uri-id"], + "uri-id" => ["uri-id"], + ] + ], "search" => [ "comment" => "", "fields" => [