getUpdateStatements()); if (count($updateStatements) === 0) { // Get count of rows in repository database table $count = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionForTable('tx_extensionmanager_domain_model_repository') ->count('*', 'tx_extensionmanager_domain_model_repository', []); if ($count === 0) { $result = true; } } else { $result = true; } return $result; } /** * @return string[] All new fields and tables must exist */ public function getPrerequisites(): array { return [ DatabaseUpdatedPrerequisite::class ]; } /** * Performs the database update. * * @return bool Whether it worked (TRUE) or not (FALSE) */ public function executeUpdate(): bool { $result = true; $sqlReader = GeneralUtility::makeInstance(SqlReader::class); $createTableStatements = $this->getTableStatements(); // First perform all create, add and change queries $schemaMigrationService = GeneralUtility::makeInstance(SchemaMigrator::class); $schemaMigrationService->install($createTableStatements); // Perform import of static data $rawDefinitions = file_get_contents( ExtensionManagementUtility::extPath('extensionmanager', 'ext_tables_static+adt.sql') ); $insertStatements = $sqlReader->getInsertStatementArray($rawDefinitions); $schemaMigrationService->importStaticData($insertStatements); return $result; } /** * Gets all create, add and change queries from ext_tables.sql * * @return array */ protected function getUpdateStatements() { $updateStatements = []; $emTableStatements = $this->getTableStatements(); if (count($emTableStatements)) { $schemaMigrationService = GeneralUtility::makeInstance(SchemaMigrator::class); $updateSuggestions = $schemaMigrationService->getUpdateSuggestions($emTableStatements); $updateStatements = array_merge_recursive(...array_values($updateSuggestions)); } return $updateStatements; } /** * Get all CREATE TABLE statements from the ext_tables.sql file * * @return string[] */ protected function getTableStatements(): array { $rawDefinitions = file_get_contents(ExtensionManagementUtility::extPath('extensionmanager', 'ext_tables.sql')); $sqlReader = GeneralUtility::makeInstance(SqlReader::class); return $sqlReader->getCreateTableStatementArray($rawDefinitions); } }