|
|
|
@ -365,6 +365,9 @@ function get_config_param_from_db($param = '') |
|
|
|
|
* @param string $databaseName |
|
|
|
|
* @param int $port |
|
|
|
|
* |
|
|
|
|
* @throws \Doctrine\DBAL\Exception |
|
|
|
|
* @throws \Doctrine\ORM\ORMException |
|
|
|
|
* |
|
|
|
|
* @return void |
|
|
|
|
*/ |
|
|
|
|
function connectToDatabase( |
|
|
|
@ -373,7 +376,8 @@ function connectToDatabase( |
|
|
|
|
$password, |
|
|
|
|
$databaseName, |
|
|
|
|
$port = 3306 |
|
|
|
|
) { |
|
|
|
|
): void |
|
|
|
|
{ |
|
|
|
|
Database::connect( |
|
|
|
|
[ |
|
|
|
|
'driver' => 'pdo_mysql', |
|
|
|
@ -1742,10 +1746,18 @@ function isUpdateAvailable(string $baseDir): bool |
|
|
|
|
|
|
|
|
|
function checkMigrationStatus(): array |
|
|
|
|
{ |
|
|
|
|
$resultStatus = [ |
|
|
|
|
'status' => false, |
|
|
|
|
'message' => 'Error executing migrations status command.', |
|
|
|
|
'current_migration' => null, |
|
|
|
|
'progress_percentage' => 0 |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$dotenv = new Dotenv(); |
|
|
|
|
$envFile = api_get_path(SYMFONY_SYS_PATH) . '.env'; |
|
|
|
|
$dotenv->loadEnv($envFile); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
connectToDatabase( |
|
|
|
|
$_ENV['DATABASE_HOST'], |
|
|
|
|
$_ENV['DATABASE_USER'], |
|
|
|
@ -1753,6 +1765,7 @@ function checkMigrationStatus(): array |
|
|
|
|
$_ENV['DATABASE_NAME'], |
|
|
|
|
$_ENV['DATABASE_PORT'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$manager = Database::getManager(); |
|
|
|
|
|
|
|
|
|
$connection = $manager->getConnection(); |
|
|
|
@ -1762,7 +1775,7 @@ function checkMigrationStatus(): array |
|
|
|
|
$dependency = DependencyFactory::fromConnection($config, new ExistingConnection($connection)); |
|
|
|
|
|
|
|
|
|
// Check if old "version" table exists from 1.11.x, use new version. |
|
|
|
|
$schema = $manager->getConnection()->getSchemaManager(); |
|
|
|
|
$schema = $manager->getConnection()->createSchemaManager(); |
|
|
|
|
$hasOldVersionTable = false; |
|
|
|
|
$anyVersionYet = !$schema->tablesExist('version'); |
|
|
|
|
$isVersionEmpty = false; |
|
|
|
@ -1813,13 +1826,9 @@ function checkMigrationStatus(): array |
|
|
|
|
'current_migration' => ($progressPercentage >= 100) ? null : $currentMigration, |
|
|
|
|
'progress_percentage' => $progressPercentage |
|
|
|
|
]; |
|
|
|
|
} else { |
|
|
|
|
$resultStatus = [ |
|
|
|
|
'status' => false, |
|
|
|
|
'message' => 'Error executing migrations status command.', |
|
|
|
|
'current_migration' => null, |
|
|
|
|
'progress_percentage' => 0 |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
} catch (Exception) { |
|
|
|
|
return $resultStatus; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $resultStatus; |
|
|
|
|