From 9a10bb4295ce7a17da73db4e7f7d8d71ab8df721 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 29 Dec 2022 16:54:08 +0100 Subject: [PATCH] Add key-value table --- database.sql | 13 ++++++++++++- doc/database.md | 1 + doc/database/db_key-value.md | 24 ++++++++++++++++++++++++ static/dbstructure.config.php | 14 +++++++++++++- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 doc/database/db_key-value.md diff --git a/database.sql b/database.sql index 7eb756cf2a..4384d44f86 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2023.03-dev (Giant Rhubarb) --- DB_UPDATE_VERSION 1504 +-- DB_UPDATE_VERSION 1505 -- ------------------------------------------ @@ -839,6 +839,17 @@ CREATE TABLE IF NOT EXISTS `intro` ( FOREIGN KEY (`suggest-cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT=''; +-- +-- TABLE key-value +-- +CREATE TABLE IF NOT EXISTS `key-value` ( + `id` int unsigned NOT NULL auto_increment COMMENT '', + `k` varbinary(50) NOT NULL DEFAULT '' COMMENT '', + `v` mediumtext COMMENT '', + PRIMARY KEY(`id`), + UNIQUE INDEX `k` (`k`) +) DEFAULT COLLATE utf8mb4_general_ci COMMENT='A key value storage'; + -- -- TABLE locks -- diff --git a/doc/database.md b/doc/database.md index 9fa438c8d2..5759d29ec7 100644 --- a/doc/database.md +++ b/doc/database.md @@ -40,6 +40,7 @@ Database Tables | [inbox-status](help/database/db_inbox-status) | Status of ActivityPub inboxes | | [intro](help/database/db_intro) | | | [item-uri](help/database/db_item-uri) | URI and GUID for items | +| [key-value](help/database/db_key-value) | A key value storage | | [locks](help/database/db_locks) | | | [mail](help/database/db_mail) | private messages | | [mailacct](help/database/db_mailacct) | Mail account data for fetching mails | diff --git a/doc/database/db_key-value.md b/doc/database/db_key-value.md new file mode 100644 index 0000000000..a346e6827e --- /dev/null +++ b/doc/database/db_key-value.md @@ -0,0 +1,24 @@ +Table key-value +=========== + +A key value storage + +Fields +------ + +| Field | Description | Type | Null | Key | Default | Extra | +| ----- | ----------- | ------------- | ---- | --- | ------- | -------------- | +| id | | int unsigned | NO | PRI | NULL | auto_increment | +| k | | varbinary(50) | NO | | | | +| v | | mediumtext | YES | | NULL | | + +Indexes +------------ + +| Name | Fields | +| ------- | --------- | +| PRIMARY | id | +| k | UNIQUE, k | + + +Return to [database documentation](help/database) diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 1d573fa87e..0128b0343e 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', 1504); + define('DB_UPDATE_VERSION', 1505); } return [ @@ -889,6 +889,18 @@ return [ "uid" => ["uid"], ] ], + "key-value" => [ + "comment" => "A key value storage", + "fields" => [ + "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""], + "k" => ["type" => "varbinary(50)", "not null" => "1", "default" => "", "comment" => ""], + "v" => ["type" => "mediumtext", "comment" => ""], + ], + "indexes" => [ + "PRIMARY" => ["id"], + "k" => ["UNIQUE", "k"], + ], + ], "locks" => [ "comment" => "", "fields" => [