From c1f849c3892fcac278da545ecde1652830e88bbb Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 22 Jul 2021 07:11:26 +0000 Subject: [PATCH] Unneeded legacy DFRN table removed --- database.sql | 17 ---------------- doc/database.md | 1 - doc/database/db_profile_check.md | 35 -------------------------------- src/Database/DBStructure.php | 2 +- src/Worker/OptimizeTables.php | 1 - static/dbstructure.config.php | 16 --------------- update.php | 4 ++-- 7 files changed, 3 insertions(+), 73 deletions(-) delete mode 100644 doc/database/db_profile_check.md diff --git a/database.sql b/database.sql index 3b9cceb06..8ae1b913b 100644 --- a/database.sql +++ b/database.sql @@ -1349,23 +1349,6 @@ CREATE TABLE IF NOT EXISTS `profile` ( FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='user profiles data'; --- --- TABLE profile_check --- -CREATE TABLE IF NOT EXISTS `profile_check` ( - `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID', - `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id', - `cid` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id', - `dfrn_id` varchar(255) NOT NULL DEFAULT '' COMMENT '', - `sec` varchar(255) NOT NULL DEFAULT '' COMMENT '', - `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '', - PRIMARY KEY(`id`), - INDEX `uid` (`uid`), - INDEX `cid` (`cid`), - FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE, - FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) DEFAULT COLLATE utf8mb4_general_ci COMMENT='DFRN remote auth use'; - -- -- TABLE profile_field -- diff --git a/doc/database.md b/doc/database.md index b1274ed32..194f30eb6 100644 --- a/doc/database.md +++ b/doc/database.md @@ -59,7 +59,6 @@ Database Tables | [post-user-notification](help/database/db_post-user-notification) | User post notifications | | [process](help/database/db_process) | Currently running system processes | | [profile](help/database/db_profile) | user profiles data | -| [profile_check](help/database/db_profile_check) | DFRN remote auth use | | [profile_field](help/database/db_profile_field) | Custom profile fields | | [push_subscriber](help/database/db_push_subscriber) | Used for OStatus: Contains feed subscribers | | [register](help/database/db_register) | registrations requiring admin approval | diff --git a/doc/database/db_profile_check.md b/doc/database/db_profile_check.md deleted file mode 100644 index 4049bd604..000000000 --- a/doc/database/db_profile_check.md +++ /dev/null @@ -1,35 +0,0 @@ -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 | -| uid | User id | mediumint unsigned | NO | | 0 | | -| cid | contact.id | int unsigned | NO | | 0 | | -| dfrn_id | | varchar(255) | NO | | | | -| 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/src/Database/DBStructure.php b/src/Database/DBStructure.php index c002c277c..d7f1179d0 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -82,7 +82,7 @@ class DBStructure $old_tables = ['fserver', 'gcign', 'gcontact', 'gcontact-relation', 'gfollower' ,'glink', 'item-delivery-data', 'item-activity', 'item-content', 'item_id', 'participation', 'poll', 'poll_result', 'queue', 'retriever_rule', 'deliverq', 'dsprphotoq', 'ffinder', 'sign', 'spam', 'term', 'user-item', 'thread', 'item', 'challenge', - 'auth_codes', 'clients', 'tokens']; + 'auth_codes', 'clients', 'tokens', 'profile_check']; $tables = DBA::selectToArray(['INFORMATION_SCHEMA' => 'TABLES'], ['TABLE_NAME'], ['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']); diff --git a/src/Worker/OptimizeTables.php b/src/Worker/OptimizeTables.php index 41c5b4a75..954b89702 100644 --- a/src/Worker/OptimizeTables.php +++ b/src/Worker/OptimizeTables.php @@ -44,7 +44,6 @@ class OptimizeTables DBA::e("OPTIMIZE TABLE `locks`"); DBA::e("OPTIMIZE TABLE `oembed`"); DBA::e("OPTIMIZE TABLE `parsed_url`"); - DBA::e("OPTIMIZE TABLE `profile_check`"); DBA::e("OPTIMIZE TABLE `session`"); Logger::info('Optimize end'); diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 24ae1bb05..ded539af5 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -1368,22 +1368,6 @@ return [ "pub_keywords" => ["FULLTEXT", "pub_keywords"], ] ], - "profile_check" => [ - "comment" => "DFRN remote auth use", - "fields" => [ - "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "User id"], - "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => "contact.id"], - "dfrn_id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "sec" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], - ], - "indexes" => [ - "PRIMARY" => ["id"], - "uid" => ["uid"], - "cid" => ["cid"], - ] - ], "profile_field" => [ "comment" => "Custom profile fields", "fields" => [ diff --git a/update.php b/update.php index 84f895838..842fefca8 100644 --- a/update.php +++ b/update.php @@ -446,7 +446,7 @@ function pre_update_1364() return Update::FAILED; } - if (!DBA::e("DELETE FROM `profile_check` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { + if (DBStructure::existsTable('profile_check') && !DBA::e("DELETE FROM `profile_check` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { return Update::FAILED; } @@ -498,7 +498,7 @@ function pre_update_1364() return Update::FAILED; } - if (!DBA::e("DELETE FROM `profile_check` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) { + if (DBStructure::existsTable('profile_check') && !DBA::e("DELETE FROM `profile_check` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) { return Update::FAILED; }