Update upgrade/install flows

This commit is contained in:
Jake Barnby
2025-12-17 18:36:23 +13:00
parent 4fb43c6e69
commit 58470bfa7f
2 changed files with 40 additions and 1 deletions
+8
View File
@@ -137,6 +137,14 @@ class Install extends Action
}
}
}
// Block database type changes on existing installations
$existingDatabase = $vars['_APP_DB_ADAPTER']['default'] ?? null;
if ($existingDatabase !== null && $existingDatabase !== $database) {
Console::error("Cannot change database type from '{$existingDatabase}' to '{$database}'.");
Console::error('Changing database types on an existing installation is not supported.');
Console::exit(1);
}
}
if (empty($httpPort)) {
+32 -1
View File
@@ -2,6 +2,8 @@
namespace Appwrite\Platform\Tasks;
use Appwrite\Docker\Compose;
use Appwrite\Docker\Env;
use Utopia\CLI\Console;
use Utopia\System\System;
use Utopia\Validator\Boolean;
@@ -41,7 +43,36 @@ class Upgrade extends Install
Console::log(' └── docker-compose.yml');
Console::exit(1);
}
$database = System::getEnv('_APP_DB_ADAPTER', 'mariadb');
// Extract existing database adapter from docker-compose.yml
$database = null;
$compose = new Compose($data);
foreach ($compose->getServices() as $service) {
if (!$service) {
continue;
}
$env = $service->getEnvironment()->list();
if (isset($env['_APP_DB_ADAPTER'])) {
$database = $env['_APP_DB_ADAPTER'];
break;
}
}
// Fallback to .env file if not found in compose
if ($database === null) {
$envData = @file_get_contents($this->path . '/.env');
if ($envData !== false) {
$envFile = new Env($envData);
$database = $envFile->list()['_APP_DB_ADAPTER'] ?? null;
}
}
// Final fallback to environment variable or default
if ($database === null) {
// TODO: Change default to 'mongodb' after next release
$database = System::getEnv('_APP_DB_ADAPTER', 'mariadb');
}
parent::action($httpPort, $httpsPort, $organization, $image, $interactive, $noStart, $database);
}
}