[Database version 1498] New table "diaspora-contact" for Diaspora contacts (duh)

- Remove duplicated "author-uri-id" keys in view declarations
This commit is contained in:
Michael 2021-08-28 07:10:27 +00:00 committed by Hypolite Petovan
parent 32a9f39768
commit d5e005f90d
5 changed files with 189 additions and 8 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2022.12-dev (Giant Rhubarb) -- Friendica 2022.12-dev (Giant Rhubarb)
-- DB_UPDATE_VERSION 1497 -- DB_UPDATE_VERSION 1498
-- ------------------------------------------ -- ------------------------------------------
@ -578,6 +578,40 @@ CREATE TABLE IF NOT EXISTS `delayed-post` (
FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE FOREIGN KEY (`wid`) REFERENCES `workerqueue` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Posts that are about to be distributed at a later time';
--
-- TABLE diaspora-contact
--
CREATE TABLE IF NOT EXISTS `diaspora-contact` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the contact URL',
`addr` varchar(255) COMMENT '',
`alias` varchar(255) COMMENT '',
`nick` varchar(255) COMMENT '',
`name` varchar(255) COMMENT '',
`given-name` varchar(255) COMMENT '',
`family-name` varchar(255) COMMENT '',
`photo` varchar(255) COMMENT '',
`photo-medium` varchar(255) COMMENT '',
`photo-small` varchar(255) COMMENT '',
`batch` varchar(255) COMMENT '',
`notify` varchar(255) COMMENT '',
`poll` varchar(255) COMMENT '',
`subscribe` varchar(255) COMMENT '',
`searchable` boolean COMMENT '',
`pubkey` text COMMENT '',
`gsid` int unsigned COMMENT 'Global Server ID',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`interacting_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts this contact interactes with',
`interacted_count` int unsigned DEFAULT 0 COMMENT 'Number of contacts that interacted with this contact',
`post_count` int unsigned DEFAULT 0 COMMENT 'Number of posts and comments',
PRIMARY KEY(`uri-id`),
UNIQUE INDEX `addr` (`addr`),
INDEX `alias` (`alias`),
INDEX `gsid` (`gsid`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Diaspora compatible contacts - used in the Diaspora implementation';
-- --
-- TABLE diaspora-interaction -- TABLE diaspora-interaction
-- --
@ -3006,3 +3040,37 @@ CREATE VIEW `profile_field-view` AS SELECT
`profile_field`.`edited` AS `edited` `profile_field`.`edited` AS `edited`
FROM `profile_field` FROM `profile_field`
INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`; INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`;
--
-- VIEW diaspora-contact-view
--
DROP VIEW IF EXISTS `diaspora-contact-view`;
CREATE VIEW `diaspora-contact-view` AS SELECT
`diaspora-contact`.`uri-id` AS `uri-id`,
`item-uri`.`uri` AS `url`,
`item-uri`.`guid` AS `guid`,
`diaspora-contact`.`addr` AS `addr`,
`diaspora-contact`.`alias` AS `alias`,
`diaspora-contact`.`nick` AS `nick`,
`diaspora-contact`.`name` AS `name`,
`diaspora-contact`.`given-name` AS `given-name`,
`diaspora-contact`.`family-name` AS `family-name`,
`diaspora-contact`.`photo` AS `photo`,
`diaspora-contact`.`photo-medium` AS `photo-medium`,
`diaspora-contact`.`photo-small` AS `photo-small`,
`diaspora-contact`.`batch` AS `batch`,
`diaspora-contact`.`notify` AS `notify`,
`diaspora-contact`.`poll` AS `poll`,
`diaspora-contact`.`subscribe` AS `subscribe`,
`diaspora-contact`.`searchable` AS `searchable`,
`diaspora-contact`.`pubkey` AS `pubkey`,
`gserver`.`url` AS `baseurl`,
`diaspora-contact`.`gsid` AS `gsid`,
`diaspora-contact`.`created` AS `created`,
`diaspora-contact`.`updated` AS `updated`,
`diaspora-contact`.`interacting_count` AS `interacting_count`,
`diaspora-contact`.`interacted_count` AS `interacted_count`,
`diaspora-contact`.`post_count` AS `post_count`
FROM `diaspora-contact`
INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`;

View File

@ -23,6 +23,7 @@ Database Tables
| [contact-relation](help/database/db_contact-relation) | Contact relations | | [contact-relation](help/database/db_contact-relation) | Contact relations |
| [conv](help/database/db_conv) | private messages | | [conv](help/database/db_conv) | private messages |
| [delayed-post](help/database/db_delayed-post) | Posts that are about to be distributed at a later time | | [delayed-post](help/database/db_delayed-post) | Posts that are about to be distributed at a later time |
| [diaspora-contact](help/database/db_diaspora-contact) | Diaspora compatible contacts - used in the Diaspora implementation |
| [diaspora-interaction](help/database/db_diaspora-interaction) | Signed Diaspora Interaction | | [diaspora-interaction](help/database/db_diaspora-interaction) | Signed Diaspora Interaction |
| [endpoint](help/database/db_endpoint) | ActivityPub endpoints - used in the ActivityPub implementation | | [endpoint](help/database/db_endpoint) | ActivityPub endpoints - used in the ActivityPub implementation |
| [event](help/database/db_event) | Events | | [event](help/database/db_event) | Events |

View File

@ -0,0 +1,52 @@
Table diaspora-contact
===========
Diaspora compatible contacts - used in the Diaspora implementation
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| ----------------- | ------------------------------------------------------------ | ------------ | ---- | --- | ------------------- | ----- |
| uri-id | Id of the item-uri table entry that contains the contact URL | int unsigned | NO | PRI | NULL | |
| addr | | varchar(255) | YES | | NULL | |
| alias | | varchar(255) | YES | | NULL | |
| nick | | varchar(255) | YES | | NULL | |
| name | | varchar(255) | YES | | NULL | |
| given-name | | varchar(255) | YES | | NULL | |
| family-name | | varchar(255) | YES | | NULL | |
| photo | | varchar(255) | YES | | NULL | |
| photo-medium | | varchar(255) | YES | | NULL | |
| photo-small | | varchar(255) | YES | | NULL | |
| batch | | varchar(255) | YES | | NULL | |
| notify | | varchar(255) | YES | | NULL | |
| poll | | varchar(255) | YES | | NULL | |
| subscribe | | varchar(255) | YES | | NULL | |
| searchable | | boolean | YES | | NULL | |
| pubkey | | text | YES | | NULL | |
| gsid | Global Server ID | int unsigned | YES | | NULL | |
| created | | datetime | NO | | 0001-01-01 00:00:00 | |
| updated | | datetime | NO | | 0001-01-01 00:00:00 | |
| interacting_count | Number of contacts this contact interactes with | int unsigned | YES | | 0 | |
| interacted_count | Number of contacts that interacted with this contact | int unsigned | YES | | 0 | |
| post_count | Number of posts and comments | int unsigned | YES | | 0 | |
Indexes
------------
| Name | Fields |
| ------- | ------------ |
| PRIMARY | uri-id |
| addr | UNIQUE, addr |
| alias | alias |
| gsid | gsid |
Foreign Keys
------------
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| uri-id | [item-uri](help/database/db_item-uri) | id |
| gsid | [gserver](help/database/db_gserver) | id |
Return to [database documentation](help/database)

View File

@ -55,7 +55,7 @@
use Friendica\Database\DBA; use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1497); define('DB_UPDATE_VERSION', 1498);
} }
return [ return [
@ -637,6 +637,39 @@ return [
"wid" => ["wid"], "wid" => ["wid"],
] ]
], ],
"diaspora-contact" => [
"comment" => "Diaspora compatible contacts - used in the Diaspora implementation",
"fields" => [
"uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the contact URL"],
"addr" => ["type" => "varchar(255)", "comment" => ""],
"alias" => ["type" => "varchar(255)", "comment" => ""],
"nick" => ["type" => "varchar(255)", "comment" => ""],
"name" => ["type" => "varchar(255)", "comment" => ""],
"given-name" => ["type" => "varchar(255)", "comment" => ""],
"family-name" => ["type" => "varchar(255)", "comment" => ""],
"photo" => ["type" => "varchar(255)", "comment" => ""],
"photo-medium" => ["type" => "varchar(255)", "comment" => ""],
"photo-small" => ["type" => "varchar(255)", "comment" => ""],
"batch" => ["type" => "varchar(255)", "comment" => ""],
"notify" => ["type" => "varchar(255)", "comment" => ""],
"poll" => ["type" => "varchar(255)", "comment" => ""],
"subscribe" => ["type" => "varchar(255)", "comment" => ""],
"searchable" => ["type" => "boolean", "comment" => ""],
"pubkey" => ["type" => "text", "comment" => ""],
"gsid" => ["type" => "int unsigned", "foreign" => ["gserver" => "id", "on delete" => "restrict"], "comment" => "Global Server ID"],
"created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
"updated" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
"interacting_count" => ["type" => "int unsigned", "default" => 0, "comment" => "Number of contacts this contact interactes with"],
"interacted_count" => ["type" => "int unsigned", "default" => 0, "comment" => "Number of contacts that interacted with this contact"],
"post_count" => ["type" => "int unsigned", "default" => 0, "comment" => "Number of posts and comments"],
],
"indexes" => [
"PRIMARY" => ["uri-id"],
"addr" => ["UNIQUE", "addr"],
"alias" => ["alias"],
"gsid" => ["gsid"],
]
],
"diaspora-interaction" => [ "diaspora-interaction" => [
"comment" => "Signed Diaspora Interaction", "comment" => "Signed Diaspora Interaction",
"fields" => [ "fields" => [

View File

@ -155,7 +155,6 @@
"author-hidden" => ["author", "hidden"], "author-hidden" => ["author", "hidden"],
"author-updated" => ["author", "updated"], "author-updated" => ["author", "updated"],
"author-gsid" => ["author", "gsid"], "author-gsid" => ["author", "gsid"],
"author-uri-id" => ["author", "uri-id"],
"owner-id" => ["post-user", "owner-id"], "owner-id" => ["post-user", "owner-id"],
"owner-uri-id" => ["owner", "uri-id"], "owner-uri-id" => ["owner", "uri-id"],
"owner-link" => ["owner", "url"], "owner-link" => ["owner", "url"],
@ -332,7 +331,6 @@
"author-hidden" => ["author", "hidden"], "author-hidden" => ["author", "hidden"],
"author-updated" => ["author", "updated"], "author-updated" => ["author", "updated"],
"author-gsid" => ["author", "gsid"], "author-gsid" => ["author", "gsid"],
"author-uri-id" => ["author", "uri-id"],
"owner-id" => ["post-thread-user", "owner-id"], "owner-id" => ["post-thread-user", "owner-id"],
"owner-uri-id" => ["owner", "uri-id"], "owner-uri-id" => ["owner", "uri-id"],
"owner-link" => ["owner", "url"], "owner-link" => ["owner", "url"],
@ -495,7 +493,6 @@
"author-hidden" => ["author", "hidden"], "author-hidden" => ["author", "hidden"],
"author-updated" => ["author", "updated"], "author-updated" => ["author", "updated"],
"author-gsid" => ["author", "gsid"], "author-gsid" => ["author", "gsid"],
"author-uri-id" => ["author", "uri-id"],
"owner-id" => ["post", "owner-id"], "owner-id" => ["post", "owner-id"],
"owner-uri-id" => ["owner", "uri-id"], "owner-uri-id" => ["owner", "uri-id"],
"owner-link" => ["owner", "url"], "owner-link" => ["owner", "url"],
@ -634,7 +631,6 @@
"author-hidden" => ["author", "hidden"], "author-hidden" => ["author", "hidden"],
"author-updated" => ["author", "updated"], "author-updated" => ["author", "updated"],
"author-gsid" => ["author", "gsid"], "author-gsid" => ["author", "gsid"],
"author-uri-id" => ["author", "uri-id"],
"owner-id" => ["post-thread", "owner-id"], "owner-id" => ["post-thread", "owner-id"],
"owner-uri-id" => ["owner", "uri-id"], "owner-uri-id" => ["owner", "uri-id"],
"owner-link" => ["owner", "url"], "owner-link" => ["owner", "url"],
@ -1019,7 +1015,7 @@
LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id` LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id`
LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id` LEFT JOIN `fcontact` ON `fcontact`.`uri-id` = contact.`uri-id`
LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid` LEFT JOIN `gserver` ON `gserver`.`id` = contact.`gsid`
WHERE `contact`.`uid` = 0" WHERE `contact`.`uid` = 0"
], ],
"account-user-view" => [ "account-user-view" => [
"fields" => [ "fields" => [
@ -1190,5 +1186,36 @@
"query" => "FROM `profile_field` "query" => "FROM `profile_field`
INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`" INNER JOIN `permissionset` ON `permissionset`.`id` = `profile_field`.`psid`"
], ],
"diaspora-contact-view" => [
"fields" => [
"uri-id" => ["diaspora-contact", "uri-id"],
"url" => ["item-uri", "uri"],
"guid" => ["item-uri", "guid"],
"addr" => ["diaspora-contact", "addr"],
"alias" => ["diaspora-contact", "alias"],
"nick" => ["diaspora-contact", "nick"],
"name" => ["diaspora-contact", "name"],
"given-name" => ["diaspora-contact", "given-name"],
"family-name" => ["diaspora-contact", "family-name"],
"photo" => ["diaspora-contact", "photo"],
"photo-medium" => ["diaspora-contact", "photo-medium"],
"photo-small" => ["diaspora-contact", "photo-small"],
"batch" => ["diaspora-contact", "batch"],
"notify" => ["diaspora-contact", "notify"],
"poll" => ["diaspora-contact", "poll"],
"subscribe" => ["diaspora-contact", "subscribe"],
"searchable" => ["diaspora-contact", "searchable"],
"pubkey" => ["diaspora-contact", "pubkey"],
"baseurl" => ["gserver", "url"],
"gsid" => ["diaspora-contact", "gsid"],
"created" => ["diaspora-contact", "created"],
"updated" => ["diaspora-contact", "updated"],
"interacting_count" => ["diaspora-contact", "interacting_count"],
"interacted_count" => ["diaspora-contact", "interacted_count"],
"post_count" => ["diaspora-contact", "post_count"],
],
"query" => "FROM `diaspora-contact`
INNER JOIN `item-uri` ON `item-uri`.`id` = `diaspora-contact`.`uri-id`
LEFT JOIN `gserver` ON `gserver`.`id` = `diaspora-contact`.`gsid`"
],
]; ];