From 96f07c7288a0b9a2433ad66ee6cef21612d90264 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 14 Jun 2021 08:53:37 +0000 Subject: [PATCH] Indexes and foreign keys added --- doc/database/db_2fa_app_specific_password.md | 18 ++++++++ doc/database/db_2fa_recovery_codes.md | 17 +++++++ doc/database/db_2fa_trusted_browser.md | 18 ++++++++ doc/database/db_addon.md | 13 ++++++ doc/database/db_apcontact.md | 23 ++++++++++ doc/database/db_application-token.md | 19 ++++++++ doc/database/db_application.md | 12 +++++ doc/database/db_attach.md | 18 ++++++++ doc/database/db_auth_codes.md | 18 ++++++++ doc/database/db_cache.md | 12 +++++ doc/database/db_challenge.md | 12 +++++ doc/database/db_clients.md | 18 ++++++++ doc/database/db_config.md | 12 +++++ doc/database/db_contact-relation.md | 19 ++++++++ doc/database/db_contact.md | 40 +++++++++++++++++ doc/database/db_conv.md | 18 ++++++++ doc/database/db_conversation.md | 13 ++++++ doc/database/db_delayed-post.md | 18 ++++++++ doc/database/db_diaspora-interaction.md | 17 +++++++ doc/database/db_event.md | 20 +++++++++ doc/database/db_fcontact.md | 13 ++++++ doc/database/db_fsuggest.md | 20 +++++++++ doc/database/db_group.md | 18 ++++++++ doc/database/db_group_member.md | 20 +++++++++ doc/database/db_gserver-tag.md | 18 ++++++++ doc/database/db_gserver.md | 14 ++++++ doc/database/db_hook.md | 13 ++++++ doc/database/db_host.md | 12 +++++ doc/database/db_inbox-status.md | 11 +++++ doc/database/db_intro.md | 20 +++++++++ doc/database/db_item-uri.md | 13 ++++++ doc/database/db_locks.md | 12 +++++ doc/database/db_mail.md | 30 +++++++++++++ doc/database/db_mailacct.md | 18 ++++++++ doc/database/db_manage.md | 20 +++++++++ doc/database/db_notification.md | 27 +++++++++++ doc/database/db_notify-threads.md | 22 +++++++++ doc/database/db_notify.md | 24 ++++++++++ doc/database/db_oembed.md | 12 +++++ doc/database/db_openwebauth-token.md | 18 ++++++++ doc/database/db_parsed_url.md | 13 ++++++ doc/database/db_pconfig.md | 18 ++++++++ doc/database/db_permissionset.md | 18 ++++++++ doc/database/db_photo.md | 24 ++++++++++ doc/database/db_post-category.md | 21 +++++++++ doc/database/db_post-content.md | 20 +++++++++ doc/database/db_post-delivery-data.md | 17 +++++++ doc/database/db_post-media.md | 18 ++++++++ doc/database/db_post-tag.md | 21 +++++++++ doc/database/db_post-thread-user.md | 38 ++++++++++++++++ doc/database/db_post-thread.md | 25 +++++++++++ doc/database/db_post-user-notification.md | 19 ++++++++ doc/database/db_post-user.md | 47 ++++++++++++++++++++ doc/database/db_post.md | 31 +++++++++++++ doc/database/db_process.md | 12 +++++ doc/database/db_profile.md | 19 ++++++++ doc/database/db_profile_check.md | 20 +++++++++ doc/database/db_profile_field.md | 21 +++++++++ doc/database/db_push_subscriber.md | 19 ++++++++ doc/database/db_register.md | 18 ++++++++ doc/database/db_search.md | 19 ++++++++ doc/database/db_session.md | 13 ++++++ doc/database/db_storage.md | 11 +++++ doc/database/db_tag.md | 13 ++++++ doc/database/db_tokens.md | 20 +++++++++ doc/database/db_user-contact.md | 19 ++++++++ doc/database/db_user.md | 21 +++++++++ doc/database/db_userd.md | 12 +++++ doc/database/db_verb.md | 12 +++++ doc/database/db_worker-ipc.md | 11 +++++ doc/database/db_workerqueue.md | 19 ++++++++ src/Database/DBStructure.php | 32 +++++++++---- view/templates/structure.tpl | 23 ++++++++++ 73 files changed, 1366 insertions(+), 8 deletions(-) diff --git a/doc/database/db_2fa_app_specific_password.md b/doc/database/db_2fa_app_specific_password.md index 6dba89bf41..dd97735035 100644 --- a/doc/database/db_2fa_app_specific_password.md +++ b/doc/database/db_2fa_app_specific_password.md @@ -3,6 +3,9 @@ Table 2fa_app_specific_password Two-factor app-specific _password +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | --------------- | ---------------------------------------- | ------------------ | ---- | --- | ------- | -------------- | | id | Password ID for revocation | mediumint unsigned | NO | PRI | NULL | auto_increment | @@ -12,4 +15,19 @@ Two-factor app-specific _password | generated | Datetime the password was generated | datetime | NO | | NULL | | | last_used | Datetime the password was last used | datetime | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_description | uid, description(190) | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_2fa_recovery_codes.md b/doc/database/db_2fa_recovery_codes.md index 30e00ef658..53574c7541 100644 --- a/doc/database/db_2fa_recovery_codes.md +++ b/doc/database/db_2fa_recovery_codes.md @@ -3,6 +3,9 @@ Table 2fa_recovery_codes Two-factor authentication recovery codes +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | --------- | ------------------------------- | ------------------ | ---- | --- | ------- | ----- | | uid | User ID | mediumint unsigned | NO | PRI | NULL | | @@ -10,4 +13,18 @@ Two-factor authentication recovery codes | generated | Datetime the code was generated | datetime | NO | | NULL | | | used | Datetime the code was used | datetime | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uid, code | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_2fa_trusted_browser.md b/doc/database/db_2fa_trusted_browser.md index 34845ba579..595d0ef5c7 100644 --- a/doc/database/db_2fa_trusted_browser.md +++ b/doc/database/db_2fa_trusted_browser.md @@ -3,6 +3,9 @@ Table 2fa_trusted_browser Two-factor authentication trusted browsers +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----------- | ------------------------------------------ | ------------------ | ---- | --- | ------- | ----- | | cookie_hash | Trusted cookie hash | varchar(80) | NO | PRI | NULL | | @@ -11,4 +14,19 @@ Two-factor authentication trusted browsers | created | Datetime the trusted browser was recorded | datetime | NO | | NULL | | | last_used | Datetime the trusted browser was last used | datetime | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | cookie_hash | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_addon.md b/doc/database/db_addon.md index 568e64a5a6..6644ebaa2a 100644 --- a/doc/database/db_addon.md +++ b/doc/database/db_addon.md @@ -3,6 +3,9 @@ Table addon registered addons +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------ | --------------------------------------------- | ------------ | ---- | --- | ------- | -------------- | | id | | int unsigned | NO | PRI | NULL | auto_increment | @@ -13,4 +16,14 @@ registered addons | timestamp | file timestamp to check for reloads | int unsigned | NO | | 0 | | | plugin_admin | 1 = has admin config, 0 = has no admin config | boolean | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| installed_name | installed, name | +| name | UNIQUE, name | + + Return to [database documentation](help/database) diff --git a/doc/database/db_apcontact.md b/doc/database/db_apcontact.md index c76c99b8b3..a7ea4e9d4c 100644 --- a/doc/database/db_apcontact.md +++ b/doc/database/db_apcontact.md @@ -3,6 +3,9 @@ Table apcontact ActivityPub compatible contacts - used in the ActivityPub implementation +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ---------------- | ---------------------------- | -------------- | ---- | --- | ------------------- | ----- | | url | URL of the contact | varbinary(255) | NO | PRI | NULL | | @@ -30,4 +33,24 @@ ActivityPub compatible contacts - used in the ActivityPub implementation | statuses_count | Number of posts | int unsigned | YES | | 0 | | | updated | | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | url | +| addr | addr(32) | +| alias | alias(190) | +| followers | followers(190) | +| baseurl | baseurl(190) | +| sharedinbox | sharedinbox(190) | +| gsid | gsid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| gsid | [gserver](help/database/db_gserver) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_application-token.md b/doc/database/db_application-token.md index e37bce6c9f..19230b10b0 100644 --- a/doc/database/db_application-token.md +++ b/doc/database/db_application-token.md @@ -3,6 +3,9 @@ Table application-token OAuth user token +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | -------------- | ------------- | ------------------ | ---- | --- | ------- | ----- | | application-id | | int unsigned | NO | PRI | NULL | | @@ -16,4 +19,20 @@ OAuth user token | follow | Follow scope | boolean | YES | | NULL | | | push | Push scope | boolean | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | application-id, uid | +| uid_id | uid, application-id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| application-id | [application](help/database/db_application) | id | +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_application.md b/doc/database/db_application.md index 461cc11881..e1743f28c7 100644 --- a/doc/database/db_application.md +++ b/doc/database/db_application.md @@ -3,6 +3,9 @@ Table application OAuth application +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------- | --------------- | ------------ | ---- | --- | ------- | -------------- | | id | generated index | int unsigned | NO | PRI | NULL | auto_increment | @@ -17,4 +20,13 @@ OAuth application | follow | Follow scope | boolean | YES | | NULL | | | push | Push scope | boolean | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| client_id | UNIQUE, client_id | + + Return to [database documentation](help/database) diff --git a/doc/database/db_attach.md b/doc/database/db_attach.md index 4cbda2a17b..218ce8b1d7 100644 --- a/doc/database/db_attach.md +++ b/doc/database/db_attach.md @@ -3,6 +3,9 @@ Table attach file attachments +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------- | ----------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | generated index | int unsigned | NO | PRI | NULL | auto_increment | @@ -21,4 +24,19 @@ file attachments | backend-class | Storage backend class | tinytext | YES | | NULL | | | backend-ref | Storage backend data reference | text | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_auth_codes.md b/doc/database/db_auth_codes.md index fef3f987c1..9ebd15cbdf 100644 --- a/doc/database/db_auth_codes.md +++ b/doc/database/db_auth_codes.md @@ -3,6 +3,9 @@ Table auth_codes OAuth usage +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------ | ----------- | ------------ | ---- | --- | ------- | ----- | | id | | varchar(40) | NO | PRI | NULL | | @@ -11,4 +14,19 @@ OAuth usage | expires | | int | NO | | 0 | | | scope | | varchar(250) | NO | | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| client_id | client_id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| client_id | [clients](help/database/db_clients) | client_id | + Return to [database documentation](help/database) diff --git a/doc/database/db_cache.md b/doc/database/db_cache.md index 300959ef38..2428a6f51a 100644 --- a/doc/database/db_cache.md +++ b/doc/database/db_cache.md @@ -3,6 +3,9 @@ Table cache Stores temporary data +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | ---------------------------- | -------------- | ---- | --- | ------------------- | ----- | | k | cache key | varbinary(255) | NO | PRI | NULL | | @@ -10,4 +13,13 @@ Stores temporary data | expires | datetime of cache expiration | datetime | NO | | 0001-01-01 00:00:00 | | | updated | datetime of cache insertion | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | k | +| k_expires | k, expires | + + Return to [database documentation](help/database) diff --git a/doc/database/db_challenge.md b/doc/database/db_challenge.md index 5988954ab8..bfd54c45da 100644 --- a/doc/database/db_challenge.md +++ b/doc/database/db_challenge.md @@ -3,6 +3,9 @@ Table challenge +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----------- | ------------- | ------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -12,4 +15,13 @@ Table challenge | type | | varchar(255) | NO | | | | | last_update | | varchar(255) | NO | | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| expire | expire | + + Return to [database documentation](help/database) diff --git a/doc/database/db_clients.md b/doc/database/db_clients.md index f907e0d969..00e5ef6c31 100644 --- a/doc/database/db_clients.md +++ b/doc/database/db_clients.md @@ -3,6 +3,9 @@ Table clients OAuth usage +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------ | ----------- | ------------------ | ---- | --- | ------- | ----- | | client_id | | varchar(20) | NO | PRI | NULL | | @@ -12,4 +15,19 @@ OAuth usage | icon | | text | YES | | NULL | | | uid | User id | mediumint unsigned | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | client_id | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_config.md b/doc/database/db_config.md index 029723510d..17c3cfee20 100644 --- a/doc/database/db_config.md +++ b/doc/database/db_config.md @@ -3,6 +3,9 @@ Table config main configuration storage +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ----------- | ------------- | ---- | --- | ------- | -------------- | | id | | int unsigned | NO | PRI | NULL | auto_increment | @@ -10,4 +13,13 @@ main configuration storage | k | | varbinary(50) | NO | | | | | v | | mediumtext | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| cat_k | UNIQUE, cat, k | + + Return to [database documentation](help/database) diff --git a/doc/database/db_contact-relation.md b/doc/database/db_contact-relation.md index 9a86b8daf7..c8dc95a3b7 100644 --- a/doc/database/db_contact-relation.md +++ b/doc/database/db_contact-relation.md @@ -3,6 +3,9 @@ Table contact-relation Contact relations +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ---------------- | --------------------------------------------------- | ------------ | ---- | --- | ------------------- | ----- | | cid | contact the related contact had interacted with | int unsigned | NO | PRI | 0 | | @@ -11,4 +14,20 @@ Contact relations | follow-updated | Date of the last update of the contact relationship | datetime | NO | | 0001-01-01 00:00:00 | | | follows | | boolean | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | cid, relation-cid | +| relation-cid | relation-cid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| cid | [contact](help/database/db_contact) | id | +| relation-cid | [contact](help/database/db_contact) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_contact.md b/doc/database/db_contact.md index 340f95e067..ae49777aa3 100644 --- a/doc/database/db_contact.md +++ b/doc/database/db_contact.md @@ -3,6 +3,9 @@ Table contact contact table +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------------------- | --------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -86,4 +89,41 @@ contact table | fetch_further_information | | tinyint unsigned | NO | | 0 | | | ffi_keyword_denylist | | text | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_name | uid, name(190) | +| self_uid | self, uid | +| alias_uid | alias(128), uid | +| pending_uid | pending, uid | +| blocked_uid | blocked, uid | +| uid_rel_network_poll | uid, rel, network, poll(64), archive | +| uid_network_batch | uid, network, batch(64) | +| batch_contact-type | batch(64), contact-type | +| addr_uid | addr(128), uid | +| nurl_uid | nurl(128), uid | +| nick_uid | nick(128), uid | +| attag_uid | attag(96), uid | +| dfrn-id | dfrn-id(64) | +| issued-id | issued-id(64) | +| network_uid_lastupdate | network, uid, last-update | +| uid_network_self_lastupdate | uid, network, self, last-update | +| uid_lastitem | uid, last-item | +| baseurl | baseurl(64) | +| uid_contact-type | uid, contact-type | +| uid_self_contact-type | uid, self, contact-type | +| self_network_uid | self, network, uid | +| gsid | gsid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | +| gsid | [gserver](help/database/db_gserver) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_conv.md b/doc/database/db_conv.md index 11bd7ac13d..a92e154c25 100644 --- a/doc/database/db_conv.md +++ b/doc/database/db_conv.md @@ -3,6 +3,9 @@ Table conv private messages +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | ----------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -14,4 +17,19 @@ private messages | updated | edited timestamp | datetime | NO | | 0001-01-01 00:00:00 | | | subject | subject of initial message | text | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_conversation.md b/doc/database/db_conversation.md index 964a98d610..eba69c9904 100644 --- a/doc/database/db_conversation.md +++ b/doc/database/db_conversation.md @@ -3,6 +3,9 @@ Table conversation Raw data and structure information for messages +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----------------- | -------------------------------------------------------------------- | ---------------- | ---- | --- | ------------------- | ----- | | item-uri | Original URI of the item - unrelated to the table with the same name | varbinary(255) | NO | PRI | NULL | | @@ -14,4 +17,14 @@ Raw data and structure information for messages | source | Original source | mediumtext | YES | | NULL | | | received | Receiving date | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | item-uri | +| conversation-uri | conversation-uri | +| received | received | + + Return to [database documentation](help/database) diff --git a/doc/database/db_delayed-post.md b/doc/database/db_delayed-post.md index 0f1c2f5cf1..16c31e46e2 100644 --- a/doc/database/db_delayed-post.md +++ b/doc/database/db_delayed-post.md @@ -3,6 +3,9 @@ Table delayed-post Posts that are about to be distributed at a later time +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | ---------------------------------------------- | ------------------ | ---- | --- | ------- | -------------- | | id | | int unsigned | NO | PRI | NULL | auto_increment | @@ -10,4 +13,19 @@ Posts that are about to be distributed at a later time | uid | Owner User id | mediumint unsigned | YES | | NULL | | | delayed | delay time | datetime | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_uri | UNIQUE, uid, uri(190) | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_diaspora-interaction.md b/doc/database/db_diaspora-interaction.md index 503c846fd9..3a15a5d19c 100644 --- a/doc/database/db_diaspora-interaction.md +++ b/doc/database/db_diaspora-interaction.md @@ -3,9 +3,26 @@ Table diaspora-interaction Signed Diaspora Interaction +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 | | | interaction | The Diaspora interaction | mediumtext | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | 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_event.md b/doc/database/db_event.md index 72cec00128..6b893dafdf 100644 --- a/doc/database/db_event.md +++ b/doc/database/db_event.md @@ -3,6 +3,9 @@ Table event Events +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | --------- | ------------------------------------------------------ | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -26,4 +29,21 @@ Events | deny_cid | Access Control - list of denied contact.id | mediumtext | YES | | NULL | | | deny_gid | Access Control - list of denied groups | mediumtext | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_start | uid, start | +| 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/doc/database/db_fcontact.md b/doc/database/db_fcontact.md index f20ca6cd05..a30bfb4ee6 100644 --- a/doc/database/db_fcontact.md +++ b/doc/database/db_fcontact.md @@ -3,6 +3,9 @@ Table fcontact Diaspora compatible contacts - used in the Diaspora implementation +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | -------- | ------------- | ---------------- | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -23,4 +26,14 @@ Diaspora compatible contacts - used in the Diaspora implementation | pubkey | | text | YES | | NULL | | | updated | | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| addr | addr(32) | +| url | UNIQUE, url(190) | + + Return to [database documentation](help/database) diff --git a/doc/database/db_fsuggest.md b/doc/database/db_fsuggest.md index d3a8e21ab5..55c36e3c1d 100644 --- a/doc/database/db_fsuggest.md +++ b/doc/database/db_fsuggest.md @@ -3,6 +3,9 @@ Table fsuggest friend suggestion stuff +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | ----------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | | int unsigned | NO | PRI | NULL | auto_increment | @@ -15,4 +18,21 @@ friend suggestion stuff | note | | text | YES | | NULL | | | created | | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| cid | cid | +| uid | uid | + +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/doc/database/db_group.md b/doc/database/db_group.md index 7ea3a0d2ff..48565aaeea 100644 --- a/doc/database/db_group.md +++ b/doc/database/db_group.md @@ -3,6 +3,9 @@ Table group privacy groups, group info +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | ------------------------------------------ | ------------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -11,4 +14,19 @@ privacy groups, group info | deleted | 1 indicates the group has been deleted | boolean | NO | | 0 | | | name | human readable name of group | varchar(255) | NO | | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_group_member.md b/doc/database/db_group_member.md index ba0960df44..adebe933bd 100644 --- a/doc/database/db_group_member.md +++ b/doc/database/db_group_member.md @@ -3,10 +3,30 @@ Table group_member privacy groups, member info +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ---------- | --------------------------------------------------------- | ------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | | gid | groups.id of the associated group | int unsigned | NO | | 0 | | | contact-id | contact.id of the member assigned to the associated group | int unsigned | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| contactid | contact-id | +| gid_contactid | UNIQUE, gid, contact-id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| gid | [group](help/database/db_group) | id | +| contact-id | [contact](help/database/db_contact) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_gserver-tag.md b/doc/database/db_gserver-tag.md index dba65c45ab..216bef1d56 100644 --- a/doc/database/db_gserver-tag.md +++ b/doc/database/db_gserver-tag.md @@ -3,9 +3,27 @@ Table gserver-tag Tags that the server has subscribed +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ---------- | ---------------------------------- | ------------ | ---- | --- | ------- | ----- | | gserver-id | The id of the gserver | int unsigned | NO | PRI | 0 | | | tag | Tag that the server has subscribed | varchar(100) | NO | PRI | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | gserver-id, tag | +| tag | tag | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| gserver-id | [gserver](help/database/db_gserver) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_gserver.md b/doc/database/db_gserver.md index 341f71eff5..5d5f2226b3 100644 --- a/doc/database/db_gserver.md +++ b/doc/database/db_gserver.md @@ -3,6 +3,9 @@ Table gserver Global servers +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ---------------- | -------------------------------------------------- | ---------------- | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -29,4 +32,15 @@ Global servers | failed | Connection failed | boolean | YES | | NULL | | | next_contact | Next connection request | datetime | YES | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| nurl | UNIQUE, nurl(190) | +| next_contact | next_contact | +| network | network | + + Return to [database documentation](help/database) diff --git a/doc/database/db_hook.md b/doc/database/db_hook.md index c25f674cc9..500e8f91d0 100644 --- a/doc/database/db_hook.md +++ b/doc/database/db_hook.md @@ -3,6 +3,9 @@ Table hook addon hook registry +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | -------- | ---------------------------------------------------------------------------------------------------------- | ----------------- | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -11,4 +14,14 @@ addon hook registry | function | function name of hook handler | varbinary(200) | NO | | | | | priority | not yet implemented - can be used to sort conflicts in hook handling by calling handlers in priority order | smallint unsigned | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| priority | priority | +| hook_file_function | UNIQUE, hook, file, function | + + Return to [database documentation](help/database) diff --git a/doc/database/db_host.md b/doc/database/db_host.md index 97fda6fa6f..802001e1b1 100644 --- a/doc/database/db_host.md +++ b/doc/database/db_host.md @@ -3,9 +3,21 @@ Table host Hostname +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ------------- | ---------------- | ---- | --- | ------- | -------------- | | id | sequential ID | tinyint unsigned | NO | PRI | NULL | auto_increment | | name | The hostname | varchar(128) | NO | | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| name | UNIQUE, name | + + Return to [database documentation](help/database) diff --git a/doc/database/db_inbox-status.md b/doc/database/db_inbox-status.md index fb6a408506..1f3463ad4b 100644 --- a/doc/database/db_inbox-status.md +++ b/doc/database/db_inbox-status.md @@ -3,6 +3,9 @@ Table inbox-status Status of ActivityPub inboxes +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | -------- | ------------------------------------ | -------------- | ---- | --- | ------------------- | ----- | | url | URL of the inbox | varbinary(255) | NO | PRI | NULL | | @@ -13,4 +16,12 @@ Status of ActivityPub inboxes | archive | Is the inbox archived? | boolean | NO | | 0 | | | shared | Is it a shared inbox? | boolean | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | url | + + Return to [database documentation](help/database) diff --git a/doc/database/db_intro.md b/doc/database/db_intro.md index 3e3731b55a..ed4dd54b69 100644 --- a/doc/database/db_intro.md +++ b/doc/database/db_intro.md @@ -3,6 +3,9 @@ Table intro +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ---------- | ------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -17,4 +20,21 @@ Table intro | blocked | | boolean | NO | | 1 | | | ignore | | boolean | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| contact-id | contact-id | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | +| contact-id | [contact](help/database/db_contact) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_item-uri.md b/doc/database/db_item-uri.md index 4b3dda5ced..3ce86fca16 100644 --- a/doc/database/db_item-uri.md +++ b/doc/database/db_item-uri.md @@ -3,10 +3,23 @@ Table item-uri URI and GUID for items +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ------------------------------- | -------------- | ---- | --- | ------- | -------------- | | id | | int unsigned | NO | PRI | NULL | auto_increment | | uri | URI of an item | varbinary(255) | NO | | NULL | | | guid | A unique identifier for an item | varbinary(255) | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uri | UNIQUE, uri | +| guid | guid | + + Return to [database documentation](help/database) diff --git a/doc/database/db_locks.md b/doc/database/db_locks.md index 3379990174..92d3e6434f 100644 --- a/doc/database/db_locks.md +++ b/doc/database/db_locks.md @@ -3,6 +3,9 @@ Table locks +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | ---------------------------- | ------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -11,4 +14,13 @@ Table locks | pid | Process ID | int unsigned | NO | | 0 | | | expires | datetime of cache expiration | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| name_expires | name, expires | + + Return to [database documentation](help/database) diff --git a/doc/database/db_mail.md b/doc/database/db_mail.md index dbdacb6d31..685dd2a0f3 100644 --- a/doc/database/db_mail.md +++ b/doc/database/db_mail.md @@ -3,6 +3,9 @@ Table mail private messages +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------- | -------------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -28,4 +31,31 @@ private messages | thr-parent-id | Id of the item-uri table that contains the thread parent uri | int unsigned | YES | | NULL | | | created | creation time of the private message | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_seen | uid, seen | +| convid | convid | +| uri | uri(64) | +| parent-uri | parent-uri(64) | +| contactid | contact-id(32) | +| author-id | author-id | +| uri-id | uri-id | +| parent-uri-id | parent-uri-id | +| thr-parent-id | thr-parent-id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | +| author-id | [contact](help/database/db_contact) | id | +| uri-id | [item-uri](help/database/db_item-uri) | id | +| parent-uri-id | [item-uri](help/database/db_item-uri) | id | +| thr-parent-id | [item-uri](help/database/db_item-uri) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_mailacct.md b/doc/database/db_mailacct.md index 8a1f380788..aaa0fa877d 100644 --- a/doc/database/db_mailacct.md +++ b/doc/database/db_mailacct.md @@ -3,6 +3,9 @@ Table mailacct Mail account data for fetching mails +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------ | ------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -19,4 +22,19 @@ Mail account data for fetching mails | pubmail | | boolean | NO | | 0 | | | last_check | | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_manage.md b/doc/database/db_manage.md index c2dadfca4d..53e5a35bb9 100644 --- a/doc/database/db_manage.md +++ b/doc/database/db_manage.md @@ -3,10 +3,30 @@ Table manage table of accounts that can manage each other +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ------------- | ------------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | | uid | User id | mediumint unsigned | NO | | 0 | | | mid | User id | mediumint unsigned | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_mid | UNIQUE, uid, mid | +| mid | mid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | +| mid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_notification.md b/doc/database/db_notification.md index 0941ff1d36..4de2a53bf7 100644 --- a/doc/database/db_notification.md +++ b/doc/database/db_notification.md @@ -3,6 +3,9 @@ Table notification notifications +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------- | ------------------------------------------------------------------------------ | ------------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -15,4 +18,28 @@ notifications | created | | datetime | YES | | NULL | | | seen | | boolean | YES | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_vid_type_actor-id_target-uri-id | UNIQUE, uid, vid, type, actor-id, target-uri-id | +| vid | vid | +| actor-id | actor-id | +| target-uri-id | target-uri-id | +| parent-uri-id | parent-uri-id | +| seen_uid | seen, uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | +| vid | [verb](help/database/db_verb) | id | +| actor-id | [contact](help/database/db_contact) | id | +| target-uri-id | [item-uri](help/database/db_item-uri) | id | +| parent-uri-id | [item-uri](help/database/db_item-uri) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_notify-threads.md b/doc/database/db_notify-threads.md index 0dd493975b..a58c45dabd 100644 --- a/doc/database/db_notify-threads.md +++ b/doc/database/db_notify-threads.md @@ -3,6 +3,9 @@ Table notify-threads +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | -------------------- | --------------------------------------------- | ------------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -12,4 +15,23 @@ Table notify-threads | parent-item | | int unsigned | NO | | 0 | | | receiver-uid | User id | mediumint unsigned | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| master-parent-uri-id | master-parent-uri-id | +| receiver-uid | receiver-uid | +| notify-id | notify-id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| notify-id | [notify](help/database/db_notify) | id | +| master-parent-uri-id | [item-uri](help/database/db_item-uri) | id | +| receiver-uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_notify.md b/doc/database/db_notify.md index a9eac5a3c8..338425ac96 100644 --- a/doc/database/db_notify.md +++ b/doc/database/db_notify.md @@ -3,6 +3,9 @@ Table notify notifications +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------- | --------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -24,4 +27,25 @@ notifications | name_cache | Cached bbcode parsing of name | tinytext | YES | | NULL | | | msg_cache | Cached bbcode parsing of msg | mediumtext | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| seen_uid_date | seen, uid, date | +| uid_date | uid, date | +| uid_type_link | uid, type, link(190) | +| uri-id | uri-id | +| parent-uri-id | parent-uri-id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | +| uri-id | [item-uri](help/database/db_item-uri) | id | +| parent-uri-id | [item-uri](help/database/db_item-uri) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_oembed.md b/doc/database/db_oembed.md index 3edee64c68..86b23f70f9 100644 --- a/doc/database/db_oembed.md +++ b/doc/database/db_oembed.md @@ -3,6 +3,9 @@ Table oembed cache for OEmbed queries +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | -------- | ------------------------------ | ------------------ | ---- | --- | ------------------- | ----- | | url | page url | varbinary(255) | NO | PRI | NULL | | @@ -10,4 +13,13 @@ cache for OEmbed queries | content | OEmbed data of the page | mediumtext | YES | | NULL | | | created | datetime of creation | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | url, maxwidth | +| created | created | + + Return to [database documentation](help/database) diff --git a/doc/database/db_openwebauth-token.md b/doc/database/db_openwebauth-token.md index 1c3060f0f4..ad598087e9 100644 --- a/doc/database/db_openwebauth-token.md +++ b/doc/database/db_openwebauth-token.md @@ -3,6 +3,9 @@ Table openwebauth-token Store OpenWebAuth token to verify contacts +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | -------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -12,4 +15,19 @@ Store OpenWebAuth token to verify contacts | meta | | varchar(255) | NO | | | | | created | datetime of creation | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_parsed_url.md b/doc/database/db_parsed_url.md index 29a3ff8521..8101883a36 100644 --- a/doc/database/db_parsed_url.md +++ b/doc/database/db_parsed_url.md @@ -3,6 +3,9 @@ Table parsed_url cache for 'parse_url' queries +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | -------- | --------------------------------- | ---------- | ---- | --- | ------------------- | ----- | | url_hash | page url hash | binary(64) | NO | PRI | NULL | | @@ -13,4 +16,14 @@ cache for 'parse_url' queries | created | datetime of creation | datetime | NO | | 0001-01-01 00:00:00 | | | expires | datetime of expiration | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | url_hash, guessing, oembed | +| created | created | +| expires | expires | + + Return to [database documentation](help/database) diff --git a/doc/database/db_pconfig.md b/doc/database/db_pconfig.md index 7449c511d3..2de6dd294c 100644 --- a/doc/database/db_pconfig.md +++ b/doc/database/db_pconfig.md @@ -3,6 +3,9 @@ Table pconfig personal (per user) configuration storage +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ----------- | ------------------ | ---- | --- | ------- | -------------- | | id | Primary key | int unsigned | NO | PRI | NULL | auto_increment | @@ -11,4 +14,19 @@ personal (per user) configuration storage | k | Key | varchar(100) | NO | | | | | v | Value | mediumtext | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_cat_k | UNIQUE, uid, cat, k | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_permissionset.md b/doc/database/db_permissionset.md index 855ed1ea12..421c67abb3 100644 --- a/doc/database/db_permissionset.md +++ b/doc/database/db_permissionset.md @@ -3,6 +3,9 @@ Table permissionset +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | --------- | ------------------------------------------------------ | ------------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -12,4 +15,19 @@ Table permissionset | deny_cid | Access Control - list of denied contact.id | mediumtext | YES | | NULL | | | deny_gid | Access Control - list of denied groups | mediumtext | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_allow_cid_allow_gid_deny_cid_deny_gid | uid, allow_cid(50), allow_gid(30), deny_cid(50), deny_gid(30) | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_photo.md b/doc/database/db_photo.md index 168797a1fb..5f98e4e349 100644 --- a/doc/database/db_photo.md +++ b/doc/database/db_photo.md @@ -3,6 +3,9 @@ Table photo photo storage +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------- | ------------------------------------------------------ | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -33,4 +36,25 @@ photo storage | backend-ref | Storage backend data reference | text | YES | | NULL | | | updated | | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| contactid | contact-id | +| uid_contactid | uid, contact-id | +| uid_profile | uid, profile | +| uid_album_scale_created | uid, album(32), scale, created | +| uid_album_resource-id_created | uid, album(32), resource-id, created | +| resource-id | resource-id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | +| contact-id | [contact](help/database/db_contact) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_post-category.md b/doc/database/db_post-category.md index 14663cf5bb..77e9ed679f 100644 --- a/doc/database/db_post-category.md +++ b/doc/database/db_post-category.md @@ -3,6 +3,9 @@ Table post-category post relation to categories +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 | | @@ -10,4 +13,22 @@ post relation to categories | type | | tinyint unsigned | NO | PRI | 0 | | | tid | | int unsigned | NO | PRI | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uri-id, uid, type, tid | +| uri-id | tid | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uri-id | [item-uri](help/database/db_item-uri) | id | +| uid | [user](help/database/db_user) | uid | +| tid | [tag](help/database/db_tag) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_post-content.md b/doc/database/db_post-content.md index 4596a04a56..5b8b258ec7 100644 --- a/doc/database/db_post-content.md +++ b/doc/database/db_post-content.md @@ -3,6 +3,9 @@ Table post-content Content for all posts +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 | | @@ -23,4 +26,21 @@ Content for all posts | resource-id | Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type | varchar(32) | NO | | | | | plink | permalink or URL to a displayable copy of the message at its source | varchar(255) | NO | | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uri-id | +| plink | plink(191) | +| resource-id | resource-id | +| title-content-warning-body | FULLTEXT, title, content-warning, body | + +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-data.md b/doc/database/db_post-delivery-data.md index 1ed912d8bc..61f8b75de5 100644 --- a/doc/database/db_post-delivery-data.md +++ b/doc/database/db_post-delivery-data.md @@ -3,6 +3,9 @@ Table post-delivery-data Delivery data for items +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 | | @@ -17,4 +20,18 @@ Delivery data for items | diaspora | Number of successful deliveries via Diaspora | mediumint | NO | | 0 | | | ostatus | Number of successful deliveries via OStatus | mediumint | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | 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-media.md b/doc/database/db_post-media.md index e1e299f02e..ef599ed135 100644 --- a/doc/database/db_post-media.md +++ b/doc/database/db_post-media.md @@ -3,6 +3,9 @@ Table post-media Attached media +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | --------------- | --------------------------------------------------------- | ----------------- | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -25,4 +28,19 @@ Attached media | publisher-name | Name of the publisher of the media | varchar(255) | YES | | NULL | | | publisher-image | Image of the publisher of the media | varbinary(255) | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uri-id-url | UNIQUE, uri-id, url | + +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-tag.md b/doc/database/db_post-tag.md index 228f27708d..30e513cab4 100644 --- a/doc/database/db_post-tag.md +++ b/doc/database/db_post-tag.md @@ -3,6 +3,9 @@ Table post-tag post relation to tags +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 | | @@ -10,4 +13,22 @@ post relation to tags | tid | | int unsigned | NO | PRI | 0 | | | cid | Contact id of the mentioned public contact | int unsigned | NO | PRI | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uri-id, type, tid, cid | +| tid | tid | +| cid | cid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uri-id | [item-uri](help/database/db_item-uri) | id | +| tid | [tag](help/database/db_tag) | id | +| cid | [contact](help/database/db_contact) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_post-thread-user.md b/doc/database/db_post-thread-user.md index 29e5617d35..875aee4aa1 100644 --- a/doc/database/db_post-thread-user.md +++ b/doc/database/db_post-thread-user.md @@ -3,6 +3,9 @@ Table post-thread-user Thread related data per user +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 | | @@ -29,4 +32,39 @@ Thread related data per user | psid | ID of the permission set of this post | int unsigned | YES | | NULL | | | post-user-id | Id of the post-user table | int unsigned | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uid, uri-id | +| uri-id | uri-id | +| owner-id | owner-id | +| author-id | author-id | +| causer-id | causer-id | +| uid | uid | +| contact-id | contact-id | +| psid | psid | +| post-user-id | post-user-id | +| commented | commented | +| uid_received | uid, received | +| uid_pinned | uid, pinned | +| uid_commented | uid, commented | +| uid_starred | uid, starred | +| uid_mention | uid, mention | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uri-id | [item-uri](help/database/db_item-uri) | id | +| owner-id | [contact](help/database/db_contact) | id | +| author-id | [contact](help/database/db_contact) | id | +| causer-id | [contact](help/database/db_contact) | id | +| uid | [user](help/database/db_user) | uid | +| contact-id | [contact](help/database/db_contact) | id | +| psid | [permissionset](help/database/db_permissionset) | id | +| post-user-id | [post-user](help/database/db_post-user) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_post-thread.md b/doc/database/db_post-thread.md index 8b847e6283..f5a8516500 100644 --- a/doc/database/db_post-thread.md +++ b/doc/database/db_post-thread.md @@ -3,6 +3,9 @@ Table post-thread Thread related data +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 | | @@ -15,4 +18,26 @@ Thread related data | changed | Date that something in the conversation changed, indicating clients should fetch the conversation again | datetime | NO | | 0001-01-01 00:00:00 | | | commented | | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uri-id | +| owner-id | owner-id | +| author-id | author-id | +| causer-id | causer-id | +| received | received | +| commented | commented | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uri-id | [item-uri](help/database/db_item-uri) | id | +| owner-id | [contact](help/database/db_contact) | id | +| author-id | [contact](help/database/db_contact) | id | +| causer-id | [contact](help/database/db_contact) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_post-user-notification.md b/doc/database/db_post-user-notification.md index 1607ce2c23..0ebe8ccaf1 100644 --- a/doc/database/db_post-user-notification.md +++ b/doc/database/db_post-user-notification.md @@ -3,10 +3,29 @@ Table post-user-notification User post notifications +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 | | | uid | Owner id which owns this copy of the item | mediumint unsigned | NO | PRI | NULL | | | notification-type | | tinyint unsigned | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uid, uri-id | +| uri-id | uri-id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uri-id | [item-uri](help/database/db_item-uri) | id | +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_post-user.md b/doc/database/db_post-user.md index 8fad8056ec..6d2f0c71b6 100644 --- a/doc/database/db_post-user.md +++ b/doc/database/db_post-user.md @@ -3,6 +3,9 @@ Table post-user User specific post data +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----------------- | --------------------------------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | | int unsigned | NO | PRI | NULL | auto_increment | @@ -36,4 +39,48 @@ User specific post data | origin | item originated at this site | boolean | NO | | 0 | | | psid | ID of the permission set of this post | int unsigned | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_uri-id | UNIQUE, uid, uri-id | +| uri-id | uri-id | +| parent-uri-id | parent-uri-id | +| thr-parent-id | thr-parent-id | +| external-id | external-id | +| owner-id | owner-id | +| author-id | author-id | +| causer-id | causer-id | +| vid | vid | +| contact-id | contact-id | +| event-id | event-id | +| psid | psid | +| author-id_uid | author-id, uid | +| author-id_received | author-id, received | +| parent-uri-id_uid | parent-uri-id, uid | +| uid_contactid | uid, contact-id | +| uid_unseen_contactid | uid, unseen, contact-id | +| uid_unseen | uid, unseen | +| uid_hidden_uri-id | uid, hidden, uri-id | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uri-id | [item-uri](help/database/db_item-uri) | id | +| parent-uri-id | [item-uri](help/database/db_item-uri) | id | +| thr-parent-id | [item-uri](help/database/db_item-uri) | id | +| external-id | [item-uri](help/database/db_item-uri) | id | +| owner-id | [contact](help/database/db_contact) | id | +| author-id | [contact](help/database/db_contact) | id | +| causer-id | [contact](help/database/db_contact) | id | +| vid | [verb](help/database/db_verb) | id | +| uid | [user](help/database/db_user) | uid | +| contact-id | [contact](help/database/db_contact) | id | +| event-id | [event](help/database/db_event) | id | +| psid | [permissionset](help/database/db_permissionset) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_post.md b/doc/database/db_post.md index afde2ef871..7d5d7cc567 100644 --- a/doc/database/db_post.md +++ b/doc/database/db_post.md @@ -3,6 +3,9 @@ Table post Structure for all posts +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 | | @@ -24,4 +27,32 @@ Structure for all posts | visible | | boolean | NO | | 0 | | | deleted | item has been marked for deletion | boolean | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uri-id | +| parent-uri-id | parent-uri-id | +| thr-parent-id | thr-parent-id | +| external-id | external-id | +| owner-id | owner-id | +| author-id | author-id | +| causer-id | causer-id | +| vid | vid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uri-id | [item-uri](help/database/db_item-uri) | id | +| parent-uri-id | [item-uri](help/database/db_item-uri) | id | +| thr-parent-id | [item-uri](help/database/db_item-uri) | id | +| external-id | [item-uri](help/database/db_item-uri) | id | +| owner-id | [contact](help/database/db_contact) | id | +| author-id | [contact](help/database/db_contact) | id | +| causer-id | [contact](help/database/db_contact) | id | +| vid | [verb](help/database/db_verb) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_process.md b/doc/database/db_process.md index 648019e835..aca53c70a1 100644 --- a/doc/database/db_process.md +++ b/doc/database/db_process.md @@ -3,10 +3,22 @@ Table process Currently running system processes +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | ----------- | ------------- | ---- | --- | ------------------- | ----- | | pid | | int unsigned | NO | PRI | NULL | | | command | | varbinary(32) | NO | | | | | created | | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | pid | +| command | command | + + Return to [database documentation](help/database) diff --git a/doc/database/db_profile.md b/doc/database/db_profile.md index be97c5d4a8..79de8ade5d 100644 --- a/doc/database/db_profile.md +++ b/doc/database/db_profile.md @@ -3,6 +3,9 @@ Table profile user profiles data +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------ | --------------------------------------------- | ------------------ | ---- | --- | ---------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -48,4 +51,20 @@ user profiles data | publish | publish default profile in local directory | boolean | NO | | 0 | | | net-publish | publish profile in global directory | boolean | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_is-default | uid, is-default | +| pub_keywords | FULLTEXT, pub_keywords | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_profile_check.md b/doc/database/db_profile_check.md index 77f4bb6188..1c7bc81476 100644 --- a/doc/database/db_profile_check.md +++ b/doc/database/db_profile_check.md @@ -3,6 +3,9 @@ Table profile_check DFRN remote auth use +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | ------------- | ------------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -12,4 +15,21 @@ DFRN remote auth use | sec | | varchar(255) | NO | | | | | expire | | int unsigned | NO | | 0 | | +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/doc/database/db_profile_field.md b/doc/database/db_profile_field.md index 7bf2e9dcd9..e920bcd1a0 100644 --- a/doc/database/db_profile_field.md +++ b/doc/database/db_profile_field.md @@ -3,6 +3,9 @@ Table profile_field Custom profile fields +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------- | ----------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -14,4 +17,22 @@ Custom profile fields | created | creation time | datetime | NO | | 0001-01-01 00:00:00 | | | edited | last edit time | datetime | NO | | 0001-01-01 00:00:00 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid | uid | +| order | order | +| psid | psid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | +| psid | [permissionset](help/database/db_permissionset) | id | + Return to [database documentation](help/database) diff --git a/doc/database/db_push_subscriber.md b/doc/database/db_push_subscriber.md index fde15de14a..9c5094b6f5 100644 --- a/doc/database/db_push_subscriber.md +++ b/doc/database/db_push_subscriber.md @@ -3,6 +3,9 @@ Table push_subscriber Used for OStatus: Contains feed subscribers +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------ | --------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -16,4 +19,20 @@ Used for OStatus: Contains feed subscribers | renewed | Date of last subscription renewal | datetime | NO | | 0001-01-01 00:00:00 | | | secret | | varchar(255) | NO | | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| next_try | next_try | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_register.md b/doc/database/db_register.md index fac22811d4..856128a425 100644 --- a/doc/database/db_register.md +++ b/doc/database/db_register.md @@ -3,6 +3,9 @@ Table register registrations requiring admin approval +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | -------- | ------------- | ------------------ | ---- | --- | ------------------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | @@ -13,4 +16,19 @@ registrations requiring admin approval | language | | varchar(16) | NO | | | | | note | | text | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_search.md b/doc/database/db_search.md index dc20ac42a5..2b7684b0b8 100644 --- a/doc/database/db_search.md +++ b/doc/database/db_search.md @@ -3,10 +3,29 @@ Table search +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ------------- | ------------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | | uid | User id | mediumint unsigned | NO | | 0 | | | term | | varchar(255) | NO | | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| uid_term | uid, term(64) | +| term | term(64) | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_session.md b/doc/database/db_session.md index d01b573647..72810e7e93 100644 --- a/doc/database/db_session.md +++ b/doc/database/db_session.md @@ -3,6 +3,9 @@ Table session web session storage +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------ | ------------- | --------------- | ---- | --- | ------- | -------------- | | id | sequential ID | bigint unsigned | NO | PRI | NULL | auto_increment | @@ -10,4 +13,14 @@ web session storage | data | | text | YES | | NULL | | | expire | | int unsigned | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| sid | sid(64) | +| expire | expire | + + Return to [database documentation](help/database) diff --git a/doc/database/db_storage.md b/doc/database/db_storage.md index 21596ba653..4278fbfd3d 100644 --- a/doc/database/db_storage.md +++ b/doc/database/db_storage.md @@ -3,9 +3,20 @@ Table storage Data stored by Database storage backend +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ------------------------------ | ------------ | ---- | --- | ------- | -------------- | | id | Auto incremented image data id | int unsigned | NO | PRI | NULL | auto_increment | | data | file data | longblob | NO | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | + + Return to [database documentation](help/database) diff --git a/doc/database/db_tag.md b/doc/database/db_tag.md index f52478c855..071eb7928d 100644 --- a/doc/database/db_tag.md +++ b/doc/database/db_tag.md @@ -3,10 +3,23 @@ Table tag tags and mentions +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ----------- | -------------- | ---- | --- | ------- | -------------- | | id | | int unsigned | NO | PRI | NULL | auto_increment | | name | | varchar(96) | NO | | | | | url | | varbinary(255) | NO | | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| type_name_url | UNIQUE, name, url | +| url | url | + + Return to [database documentation](help/database) diff --git a/doc/database/db_tokens.md b/doc/database/db_tokens.md index bf20f16b82..1169100549 100644 --- a/doc/database/db_tokens.md +++ b/doc/database/db_tokens.md @@ -3,6 +3,9 @@ Table tokens OAuth usage +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | --------- | ----------- | ------------------ | ---- | --- | ------- | ----- | | id | | varchar(40) | NO | PRI | NULL | | @@ -12,4 +15,21 @@ OAuth usage | scope | | varchar(200) | NO | | | | | uid | User id | mediumint unsigned | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| client_id | client_id | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| client_id | [clients](help/database/db_clients) | client_id | +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_user-contact.md b/doc/database/db_user-contact.md index 9bcbff7d33..8c8f12f75b 100644 --- a/doc/database/db_user-contact.md +++ b/doc/database/db_user-contact.md @@ -3,6 +3,9 @@ Table user-contact User specific public contact data +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | --------- | ------------------------------------------- | ------------------ | ---- | --- | ------- | ----- | | cid | Contact id of the linked public contact | int unsigned | NO | PRI | 0 | | @@ -11,4 +14,20 @@ User specific public contact data | ignored | Posts from this contact are ignored | boolean | YES | | NULL | | | collapsed | Posts from this contact are collapsed | boolean | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uid, cid | +| cid | cid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| cid | [contact](help/database/db_contact) | id | +| uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_user.md b/doc/database/db_user.md index 8cc762cc22..8104e0f0f3 100644 --- a/doc/database/db_user.md +++ b/doc/database/db_user.md @@ -3,6 +3,9 @@ Table user The local users +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ------------------------ | --------------------------------------------------------- | ------------------ | ---- | --- | ------------------- | -------------- | | uid | sequential ID | mediumint unsigned | NO | PRI | NULL | auto_increment | @@ -51,4 +54,22 @@ The local users | deny_gid | default permission for this user | mediumtext | YES | | NULL | | | openidserver | | text | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | uid | +| nickname | nickname(32) | +| parent-uid | parent-uid | +| guid | guid | +| email | email(64) | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| parent-uid | [user](help/database/db_user) | uid | + Return to [database documentation](help/database) diff --git a/doc/database/db_userd.md b/doc/database/db_userd.md index eaef348749..cca71a2722 100644 --- a/doc/database/db_userd.md +++ b/doc/database/db_userd.md @@ -3,9 +3,21 @@ Table userd Deleted usernames +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | -------- | ------------- | ------------ | ---- | --- | ------- | -------------- | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | | username | | varchar(255) | NO | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| username | username(32) | + + Return to [database documentation](help/database) diff --git a/doc/database/db_verb.md b/doc/database/db_verb.md index cd5d66f835..6613225f93 100644 --- a/doc/database/db_verb.md +++ b/doc/database/db_verb.md @@ -3,9 +3,21 @@ Table verb Activity Verbs +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ----------- | ----------------- | ---- | --- | ------- | -------------- | | id | | smallint unsigned | NO | PRI | NULL | auto_increment | | name | | varchar(100) | NO | | | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| name | name | + + Return to [database documentation](help/database) diff --git a/doc/database/db_worker-ipc.md b/doc/database/db_worker-ipc.md index 57ec489352..ac34d4649f 100644 --- a/doc/database/db_worker-ipc.md +++ b/doc/database/db_worker-ipc.md @@ -3,9 +3,20 @@ Table worker-ipc Inter process communication between the frontend and the worker +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | ----- | ------------------------- | ------- | ---- | --- | ------- | ----- | | key | | int | NO | PRI | NULL | | | jobs | Flag for outstanding jobs | boolean | YES | | NULL | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | key | + + Return to [database documentation](help/database) diff --git a/doc/database/db_workerqueue.md b/doc/database/db_workerqueue.md index 16b6a2e0d8..7510b7a762 100644 --- a/doc/database/db_workerqueue.md +++ b/doc/database/db_workerqueue.md @@ -3,6 +3,9 @@ Table workerqueue Background tasks queue entries +Fields +------ + | Field | Description | Type | Null | Key | Default | Extra | | --------- | ------------------------------------------------------- | ---------------- | ---- | --- | ------------------- | -------------- | | id | Auto incremented worker task id | int unsigned | NO | PRI | NULL | auto_increment | @@ -16,4 +19,20 @@ Background tasks queue entries | retrial | Retrial counter | tinyint | NO | | 0 | | | done | Marked 1 when the task was done - will be deleted later | boolean | NO | | 0 | | +Indexes +------------ + +| Name | Fields | +|------|---------| +| PRIMARY | id | +| command | command | +| done_command_parameter | done, command, parameter(64) | +| done_executed | done, executed | +| done_priority_retrial_created | done, priority, retrial, created | +| done_priority_next_try | done, priority, next_try | +| done_pid_next_try | done, pid, next_try | +| done_pid_retrial | done, pid, retrial | +| done_pid_priority_created | done, pid, priority, created | + + Return to [database documentation](help/database) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 4451b09ab6..864f2ded3f 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -166,6 +166,12 @@ class DBStructure $tables = []; foreach (self::definition(null) as $name => $definition) { + $indexes = []; + foreach ($definition['indexes'] as $key => $value) { + $indexes[] = ['name' => $key, 'fields' => implode(', ', $value)]; + } + + $foreign = []; $fields = [[ 'name' => 'Field', 'comment' => 'Description', @@ -174,7 +180,7 @@ class DBStructure 'primary' => 'Key', 'default' => 'Default', 'extra' => 'Extra', - ], + ], [ 'name' => '-', 'comment' => '-', @@ -202,33 +208,43 @@ class DBStructure $field['primary'] = ($value['primary'] ?? false) ? 'PRI' : ''; $field['default'] = $value['default'] ?? 'NULL'; $field['extra'] = $value['extra'] ?? ''; - + foreach ($field as $fieldname => $fieldvalue) { $lengths[$fieldname] = max($lengths[$fieldname] ?? 0, strlen($fieldvalue)); } $fields[] = $field; + + if (!empty($value['foreign'])) { + $foreign[] = [ + 'field' => $key, + 'targettable' => array_keys($value['foreign'])[0], + 'targetfield' => array_values($value['foreign'])[0] + ]; + } } array_walk_recursive($fields, function(&$value, $key) use ($lengths) { $value = str_pad($value, $lengths[$key], $value === '-' ? '-' : ' '); }); - + $tables[] = ['name' => $name, 'comment' => $definition['comment']]; $content = Renderer::replaceMacros(Renderer::getMarkupTemplate('structure.tpl'), [ '$name' => $name, '$comment' => $definition['comment'], '$fields' => $fields, + '$indexes' => $indexes, + '$foreign' => $foreign, ]); $filename = DI::basePath() . '/doc/database/db_' . $name . '.md'; file_put_contents($filename, $content); } asort($tables); $content = Renderer::replaceMacros(Renderer::getMarkupTemplate('tables.tpl'), [ - '$tables' => $tables, + '$tables' => $tables, ]); $filename = DI::basePath() . '/doc/database.md'; - file_put_contents($filename, $content); + file_put_contents($filename, $content); } public static function printStructure($basePath) @@ -1278,7 +1294,7 @@ class DBStructure if ($verbose) { echo "Zero contact added\n"; } - } + } } elseif (self::existsTable('contact') && $verbose) { echo "Zero contact already added\n"; } elseif ($verbose) { @@ -1302,7 +1318,7 @@ class DBStructure if (self::existsTable('permissionset')) { if (!DBA::exists('permissionset', ['id' => 0])) { - DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']); + DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']); $lastid = DBA::lastInsertId(); if ($lastid != 0) { DBA::update('permissionset', ['id' => 0], ['id' => $lastid]); @@ -1337,7 +1353,7 @@ class DBStructure } elseif ($verbose) { echo "permissionset: Table not found\n"; } - + if (!self::existsForeignKeyForField('tokens', 'client_id')) { $tokens = DBA::p("SELECT `tokens`.`id` FROM `tokens` LEFT JOIN `clients` ON `clients`.`client_id` = `tokens`.`client_id` diff --git a/view/templates/structure.tpl b/view/templates/structure.tpl index 3ec9ba9b2d..14704973a0 100644 --- a/view/templates/structure.tpl +++ b/view/templates/structure.tpl @@ -3,8 +3,31 @@ Table {{$name}} {{$comment}} +Fields +------ + {{foreach $fields as $field}} | {{$field.name}} | {{$field.comment}} | {{$field.type}} | {{$field.null}} | {{$field.primary}} | {{$field.default}} | {{$field.extra}} | {{/foreach}} +Indexes +------------ + +| Name | Fields | +|------|---------| +{{foreach $indexes as $index}} +| {{$index.name}} | {{$index.fields}} | +{{/foreach}} + +{{if $foreign}} +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +{{foreach $foreign as $key}} +| {{$key.field}} | [{{$key.targettable}}](help/database/db_{{$key.targettable}}) | {{$key.targetfield}} | +{{/foreach}} +{{/if}} + Return to [database documentation](help/database)