From b47ac00ca8161b1a73fa2c7c933a9a4f220f57ef Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 31 Mar 2026 21:08:29 +1300 Subject: [PATCH] (refactor): rename migrate param and add --migrate flag to upgrade task --- app/views/install/installer/js/modules/progress.js | 2 +- app/views/install/installer/js/steps.js | 10 +++++----- .../install/installer/templates/steps/step-6.phtml | 2 +- .../Platform/Installer/Http/Installer/Install.php | 6 +++--- src/Appwrite/Platform/Tasks/Install.php | 7 ++++--- src/Appwrite/Platform/Tasks/Upgrade.php | 5 ++++- tests/unit/Platform/Modules/Installer/ModuleTest.php | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/views/install/installer/js/modules/progress.js b/app/views/install/installer/js/modules/progress.js index 9087a192ef..868f820c95 100644 --- a/app/views/install/installer/js/modules/progress.js +++ b/app/views/install/installer/js/modules/progress.js @@ -374,7 +374,7 @@ assistantOpenAIKey: normalizedAssistantKey, accountEmail: normalizedAccountEmail, accountPassword: normalizedAccountPassword, - runMigration: formState?.runMigration ?? false + migrate: formState?.migrate ?? false }; }; diff --git a/app/views/install/installer/js/steps.js b/app/views/install/installer/js/steps.js index fb76b5f72d..b34389b561 100644 --- a/app/views/install/installer/js/steps.js +++ b/app/views/install/installer/js/steps.js @@ -337,14 +337,14 @@ const checkbox = root.querySelector('#run-migration'); if (checkbox) { - if (formState.runMigration !== undefined) { - checkbox.checked = formState.runMigration; + if (formState.migrate !== undefined) { + checkbox.checked = formState.migrate; } else { - formState.runMigration = checkbox.checked; + formState.migrate = checkbox.checked; } checkbox.addEventListener('change', () => { - formState.runMigration = checkbox.checked; - dispatchStateChange?.('runMigration'); + formState.migrate = checkbox.checked; + dispatchStateChange?.('migrate'); }); } diff --git a/app/views/install/installer/templates/steps/step-6.phtml b/app/views/install/installer/templates/steps/step-6.phtml index ca253c9907..9a8838ae3a 100644 --- a/app/views/install/installer/templates/steps/step-6.phtml +++ b/app/views/install/installer/templates/steps/step-6.phtml @@ -17,7 +17,7 @@ $isUpgrade = $isUpgrade ?? false; Recommended when upgrading to a new version - + diff --git a/src/Appwrite/Platform/Installer/Http/Installer/Install.php b/src/Appwrite/Platform/Installer/Http/Installer/Install.php index 482a30eab4..8aaaf621bb 100644 --- a/src/Appwrite/Platform/Installer/Http/Installer/Install.php +++ b/src/Appwrite/Platform/Installer/Http/Installer/Install.php @@ -43,7 +43,7 @@ class Install extends Action ->param('database', '', new WhiteList(['mongodb', 'mariadb', 'postgresql']), 'Database adapter', true) ->param('installId', '', new Text(64, 0), 'Installation ID', true) ->param('retryStep', null, new Nullable(new WhiteList([Server::STEP_DOCKER_COMPOSE, Server::STEP_ENV_VARS, Server::STEP_DOCKER_CONTAINERS], true)), 'Retry from step', true) - ->param('runMigration', false, new \Utopia\Validator\Boolean(true), 'Run database migration after upgrade', true) + ->param('migrate', false, new \Utopia\Validator\Boolean(true), 'Run database migration after upgrade', true) ->inject('request') ->inject('response') ->inject('swooleResponse') @@ -65,7 +65,7 @@ class Install extends Action string $database, string $installId, ?string $retryStep, - bool $runMigration, + bool $migrate, Request $request, Response $response, SwooleResponse $swooleResponse, @@ -357,7 +357,7 @@ class Install extends Action $config->isUpgrade(), $account, $onComplete, - $runMigration, + $migrate, ); $onComplete(); diff --git a/src/Appwrite/Platform/Tasks/Install.php b/src/Appwrite/Platform/Tasks/Install.php index 95846aad87..1be10f537f 100644 --- a/src/Appwrite/Platform/Tasks/Install.php +++ b/src/Appwrite/Platform/Tasks/Install.php @@ -36,6 +36,7 @@ class Install extends Action private const string GROWTH_API_URL = 'https://growth.appwrite.io/v1'; protected bool $isUpgrade = false; + protected bool $migrate = false; protected string $hostPath = ''; protected ?bool $isLocalInstall = null; protected ?array $installerConfig = null; @@ -323,7 +324,7 @@ class Install extends Action $shouldGenerateSecrets = !$existingInstallation && !$isUpgrade; $input = $this->prepareEnvironmentVariables($userInput, $vars, $shouldGenerateSecrets); - $this->performInstallation($httpPort, $httpsPort, $organization, $image, $input, $noStart, null, null, $isUpgrade); + $this->performInstallation($httpPort, $httpsPort, $organization, $image, $input, $noStart, null, null, $isUpgrade, migrate: $this->migrate); } @@ -514,7 +515,7 @@ class Install extends Action bool $isUpgrade = false, array $account = [], ?callable $onComplete = null, - bool $runMigration = false, + bool $migrate = false, ): void { $isLocalInstall = $this->isLocalInstall(); $this->applyLocalPaths($isLocalInstall, false); @@ -637,7 +638,7 @@ class Install extends Action $this->createInitialAdminAccount($account, $progress, $apiUrl, $domain); } - if ($isUpgrade && $runMigration) { + if ($isUpgrade && $migrate) { // Allow the containers-completed SSE event to flush // before blocking on migration exec usleep(200_000); diff --git a/src/Appwrite/Platform/Tasks/Upgrade.php b/src/Appwrite/Platform/Tasks/Upgrade.php index 1d61180963..6ef9c7134d 100644 --- a/src/Appwrite/Platform/Tasks/Upgrade.php +++ b/src/Appwrite/Platform/Tasks/Upgrade.php @@ -30,6 +30,7 @@ class Upgrade extends Install ->param('interactive', 'Y', new Text(1), 'Run an interactive session', true) ->param('no-start', false, new Boolean(true), 'Run an interactive session', true) ->param('database', 'mongodb', new Text(length: 0), 'Database to use (mongodb|mariadb|postgresql)', true) + ->param('migrate', true, new Boolean(true), 'Run database migration after upgrade', true) ->callback($this->action(...)); } @@ -40,9 +41,11 @@ class Upgrade extends Install string $image, string $interactive, bool $noStart, - string $database + string $database, + bool $migrate = true, ): void { $this->isUpgrade = true; + $this->migrate = $migrate; $isLocalInstall = $this->isLocalInstall(); $this->applyLocalPaths($isLocalInstall, true); diff --git a/tests/unit/Platform/Modules/Installer/ModuleTest.php b/tests/unit/Platform/Modules/Installer/ModuleTest.php index ff77a7d010..507a4e25f6 100644 --- a/tests/unit/Platform/Modules/Installer/ModuleTest.php +++ b/tests/unit/Platform/Modules/Installer/ModuleTest.php @@ -134,7 +134,7 @@ class ModuleTest extends TestCase $this->assertActionParams($action, [ 'appDomain', 'httpPort', 'httpsPort', 'emailCertificates', 'opensslKey', 'assistantOpenAIKey', 'accountEmail', 'accountPassword', 'database', - 'installId', 'retryStep', 'runMigration', + 'installId', 'retryStep', 'migrate', ]); $this->assertActionInjects($action, ['request', 'response', 'swooleResponse', 'installerState', 'installerConfig', 'installerPaths']); }