X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FDBStructure.php;h=d14e791e2c5ed5f7cde01ce64104e6c2e58ff00c;hb=d7212cbbbcf3f92e6d2935b3b4c596016b8f167d;hp=b4f8ed13291564a24e3ea069ba13f766652c7ddd;hpb=a910fd8864f5f1e9c35e9065abad24353793f313;p=friendica.git diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index b4f8ed1329..d14e791e2c 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -74,7 +74,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', 'tokens', 'clients', 'profile_check', 'host']; + 'auth_codes', 'tokens', 'clients', 'profile_check', 'host', 'conversation']; $tables = DBA::selectToArray('INFORMATION_SCHEMA.TABLES', ['TABLE_NAME'], ['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']); @@ -142,6 +142,7 @@ class DBStructure * Print out database error messages * * @param string $message Message to be added to the error message + * * @return string Error message */ private static function printUpdateError(string $message): string @@ -155,6 +156,7 @@ class DBStructure /** * Perform a database structure dryrun (means: just simulating) * + * @return string Empty string if the update is successful, error messages otherwise * @throws Exception */ public static function dryRun(): string @@ -513,28 +515,28 @@ class DBStructure $fields = DBA::selectToArray('INFORMATION_SCHEMA.COLUMNS', ['COLUMN_NAME', 'COLUMN_TYPE', 'IS_NULLABLE', 'COLUMN_DEFAULT', 'EXTRA', - 'COLUMN_KEY', 'COLLATION_NAME', 'COLUMN_COMMENT'], + 'COLUMN_KEY', 'COLLATION_NAME', 'COLUMN_COMMENT'], ["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?", - DBA::databaseName(), $table]); + DBA::databaseName(), $table]); $foreign_keys = DBA::selectToArray('INFORMATION_SCHEMA.KEY_COLUMN_USAGE', ['COLUMN_NAME', 'CONSTRAINT_NAME', 'REFERENCED_TABLE_NAME', 'REFERENCED_COLUMN_NAME'], ["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL", - DBA::databaseName(), $table]); + DBA::databaseName(), $table]); $table_status = DBA::selectFirst('INFORMATION_SCHEMA.TABLES', ['ENGINE', 'TABLE_COLLATION', 'TABLE_COMMENT'], ["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?", - DBA::databaseName(), $table]); + DBA::databaseName(), $table]); - $fielddata = []; - $indexdata = []; + $fielddata = []; + $indexdata = []; $foreigndata = []; if (DBA::isResult($foreign_keys)) { foreach ($foreign_keys as $foreign_key) { - $parameters = ['foreign' => [$foreign_key['REFERENCED_TABLE_NAME'] => $foreign_key['REFERENCED_COLUMN_NAME']]]; - $constraint = self::getConstraintName($table, $foreign_key['COLUMN_NAME'], $parameters); + $parameters = ['foreign' => [$foreign_key['REFERENCED_TABLE_NAME'] => $foreign_key['REFERENCED_COLUMN_NAME']]]; + $constraint = self::getConstraintName($table, $foreign_key['COLUMN_NAME'], $parameters); $foreigndata[$constraint] = $foreign_key; } } @@ -562,8 +564,8 @@ class DBStructure $fielddata = []; if (DBA::isResult($fields)) { foreach ($fields as $field) { - $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)']; - $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int']; + $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)']; + $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int']; $field['COLUMN_TYPE'] = str_replace($search, $replace, $field['COLUMN_TYPE']); $fielddata[$field['COLUMN_NAME']]['type'] = $field['COLUMN_TYPE']; @@ -585,13 +587,13 @@ class DBStructure } $fielddata[$field['COLUMN_NAME']]['Collation'] = $field['COLLATION_NAME']; - $fielddata[$field['COLUMN_NAME']]['comment'] = $field['COLUMN_COMMENT']; + $fielddata[$field['COLUMN_NAME']]['comment'] = $field['COLUMN_COMMENT']; } } return [ - 'fields' => $fielddata, - 'indexes' => $indexdata, + 'fields' => $fielddata, + 'indexes' => $indexdata, 'foreign_keys' => $foreigndata, 'table_status' => $table_status ]; @@ -722,7 +724,7 @@ class DBStructure { return DBA::exists('INFORMATION_SCHEMA.KEY_COLUMN_USAGE', ["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL", - DBA::databaseName(), $table, $field]); + DBA::databaseName(), $table, $field]); } /** @@ -795,8 +797,8 @@ class DBStructure if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) { $user = [ - 'verified' => true, - 'page-flags' => User::PAGE_FLAGS_SOAPBOX, + 'verified' => true, + 'page-flags' => User::PAGE_FLAGS_SOAPBOX, 'account-type' => User::ACCOUNT_TYPE_RELAY, ]; DBA::insert('user', $user); @@ -872,7 +874,7 @@ class DBStructure $permission = ''; } $fields = ['id' => $set['psid'], 'uid' => $set['uid'], 'allow_cid' => $permission, - 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']; + 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']; DBA::insert('permissionset', $fields); } DBA::close($sets); @@ -902,7 +904,7 @@ class DBStructure $isUpdate = false; $processes = DBA::select('information_schema.processlist', ['info'], [ - 'db' => DBA::databaseName(), + 'db' => DBA::databaseName(), 'command' => ['Query', 'Execute'] ]);