From cda03f63ab6e19274621c14ccbcf194a0ab439de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 16 Jan 2026 13:23:46 +0100 Subject: [PATCH 1/2] Support dual-writing for new schema features --- app/config/collections/common.php | 11 +++ app/config/collections/projects.php | 99 +++++++++++++++++++ app/controllers/api/teams.php | 1 + app/controllers/api/vcs.php | 1 + .../Platform/Modules/Compute/Base.php | 2 + .../Functions/Http/Deployments/Create.php | 2 + .../Http/Deployments/Duplicate/Create.php | 1 + .../Http/Deployments/Template/Create.php | 1 + .../Functions/Http/Functions/Create.php | 7 +- .../Functions/Http/Functions/Update.php | 3 + .../Modules/Sites/Http/Deployments/Create.php | 2 + .../Http/Deployments/Duplicate/Create.php | 1 + .../Http/Deployments/Template/Create.php | 1 + .../Modules/Sites/Http/Sites/Create.php | 4 + .../Modules/Sites/Http/Sites/Update.php | 4 + 15 files changed, 139 insertions(+), 1 deletion(-) diff --git a/app/config/collections/common.php b/app/config/collections/common.php index a364a0a866..2328cd5b88 100644 --- a/app/config/collections/common.php +++ b/app/config/collections/common.php @@ -1288,6 +1288,17 @@ return [ 'array' => false, 'filters' => ['json'], ], + [ + '$id' => ID::custom('labels'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => true, + 'filters' => [], + ], ], 'indexes' => [ [ diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index dae0337dc9..da4b52a526 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -567,6 +567,17 @@ return [ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('deploymentRetention'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => 0, + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('deploymentInternalId'), 'type' => Database::VAR_STRING, @@ -765,6 +776,17 @@ return [ 'default' => null, 'filters' => [], ], + [ + 'array' => false, + '$id' => ID::custom('startCommand'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 20000, + 'signed' => true, + 'required' => false, + 'default' => null, + 'filters' => [], + ], [ 'array' => false, '$id' => ID::custom('specification'), @@ -776,6 +798,28 @@ return [ 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, 'filters' => [], ], + [ + 'array' => false, + '$id' => ID::custom('buildSpecification'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => false, + 'required' => false, + 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, + 'filters' => [], + ], + [ + 'array' => false, + '$id' => ID::custom('runtimeSpecification'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => false, + 'required' => false, + 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, + 'filters' => [], + ], [ '$id' => ID::custom('scopes'), 'type' => Database::VAR_STRING, @@ -1035,6 +1079,17 @@ return [ 'default' => null, 'filters' => [], ], + [ + 'array' => false, + '$id' => ID::custom('startCommand'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 20000, + 'signed' => true, + 'required' => false, + 'default' => null, + 'filters' => [], + ], [ '$id' => ID::custom('fallbackFile'), 'type' => Database::VAR_STRING, @@ -1046,6 +1101,17 @@ return [ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('deploymentRetention'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => 0, + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('deploymentInternalId'), 'type' => Database::VAR_STRING, @@ -1200,6 +1266,28 @@ return [ 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, 'filters' => [], ], + [ + 'array' => false, + '$id' => ID::custom('buildSpecification'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => false, + 'required' => false, + 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, + 'filters' => [], + ], + [ + 'array' => false, + '$id' => ID::custom('runtimeSpecification'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => false, + 'required' => false, + 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, + 'filters' => [], + ], [ '$id' => ID::custom('buildRuntime'), 'type' => Database::VAR_STRING, @@ -1357,6 +1445,17 @@ return [ 'default' => null, 'filters' => [], ], + [ + 'array' => false, + '$id' => ID::custom('startCommand'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 20000, + 'signed' => true, + 'required' => false, + 'default' => null, + 'filters' => [], + ], [ 'array' => false, '$id' => ID::custom('buildOutput'), diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index a68939daa3..2cee394a9c 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -103,6 +103,7 @@ App::post('/v1/teams') Permission::update(Role::team($teamId, 'owner')), Permission::delete(Role::team($teamId, 'owner')), ], + 'labels' => [], 'name' => $name, 'total' => ($isPrivilegedUser || $isAppUser) ? 0 : 1, 'prefs' => new \stdClass(), diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 2270f4fd89..2bb9c17fd3 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -306,6 +306,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId 'resourceType' => $resourceCollection, 'entrypoint' => $resource->getAttribute('entrypoint', ''), 'buildCommands' => \implode(' && ', $commands), + 'startCommand' => $resource->getAttribute('startCommand', ''), 'buildOutput' => $resource->getAttribute('outputDirectory', ''), 'adapter' => $resource->getAttribute('adapter', ''), 'fallbackFile' => $resource->getAttribute('fallbackFile', ''), diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 33b69dd589..749a9fe87a 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -107,6 +107,7 @@ class Base extends Action 'resourceType' => 'functions', 'entrypoint' => $entrypoint, 'buildCommands' => $function->getAttribute('commands', ''), + 'startCommand' => $function->getAttribute('startCommand', ''), 'type' => 'vcs', 'installationId' => $installation->getId(), 'installationInternalId' => $installation->getSequence(), @@ -203,6 +204,7 @@ class Base extends Action 'resourceInternalId' => $site->getSequence(), 'resourceType' => 'sites', 'buildCommands' => implode(' && ', $commands), + 'startCommand' => $site->getAttribute('startCommand', ''), 'buildOutput' => $site->getAttribute('outputDirectory', ''), 'adapter' => $site->getAttribute('adapter', ''), 'fallbackFile' => $site->getAttribute('fallbackFile', ''), diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php index c5ae08728d..97c669b9fb 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php @@ -246,6 +246,7 @@ class Create extends Action 'resourceType' => 'functions', 'entrypoint' => $entrypoint, 'buildCommands' => $commands, + 'startCommand' => $function->getAttribute('startCommand', ''), 'sourcePath' => $path, 'sourceSize' => $fileSize, 'totalSize' => $fileSize, @@ -283,6 +284,7 @@ class Create extends Action 'resourceType' => 'functions', 'entrypoint' => $entrypoint, 'buildCommands' => $commands, + 'startCommand' => $function->getAttribute('startCommand', ''), 'sourcePath' => $path, 'sourceSize' => $fileSize, 'totalSize' => $fileSize, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php index 42bf625d78..11d9c77b0e 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php @@ -104,6 +104,7 @@ class Create extends Action 'totalSize' => $deployment->getAttribute('sourceSize', 0), 'entrypoint' => $function->getAttribute('entrypoint'), 'buildCommands' => $function->getAttribute('commands', ''), + 'startCommand' => $function->getAttribute('startCommand', ''), 'buildStartedAt' => null, 'buildEndedAt' => null, 'buildDuration' => null, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php index acfaa965ac..d4bf7446fb 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php @@ -159,6 +159,7 @@ class Create extends Base 'resourceType' => 'functions', 'entrypoint' => $function->getAttribute('entrypoint', ''), 'buildCommands' => $function->getAttribute('commands', ''), + 'startCommand' => $function->getAttribute('startCommand', ''), 'providerRepositoryName' => $repository, 'providerRepositoryOwner' => $owner, 'providerRepositoryUrl' => $repositoryUrl, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php index 6ad488283e..79c6afb92b 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php @@ -223,6 +223,8 @@ class Create extends Base 'entrypoint' => $entrypoint, 'commands' => $commands, 'scopes' => $scopes, + 'deploymentRetention' => 0, + 'startCommand' => '', 'search' => implode(' ', [$functionId, $name, $runtime]), 'version' => 'v5', 'installationId' => $installation->getId(), @@ -233,7 +235,9 @@ class Create extends Base 'providerBranch' => $providerBranch, 'providerRootDirectory' => $providerRootDirectory, 'providerSilentMode' => $providerSilentMode, - 'specification' => $specification + 'specification' => $specification, + 'buildSpecification' => $specification, + 'runtimeSpecification' => $specification, ])); } catch (DuplicateException) { throw new Exception(Exception::FUNCTION_ALREADY_EXISTS); @@ -343,6 +347,7 @@ class Create extends Base 'resourceType' => 'functions', 'entrypoint' => $function->getAttribute('entrypoint', ''), 'buildCommands' => $function->getAttribute('commands', ''), + 'startCommand' => $function->getAttribute('startCommand', ''), 'type' => 'manual', 'activate' => true, ])); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php index 55c5b30418..f2925f52be 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php @@ -261,6 +261,7 @@ class Update extends Base 'entrypoint' => $entrypoint, 'commands' => $commands, 'scopes' => $scopes, + 'deploymentRetention' => 0, 'installationId' => $installation->getId(), 'installationInternalId' => $installation->getSequence(), 'providerRepositoryId' => $providerRepositoryId, @@ -270,6 +271,8 @@ class Update extends Base 'providerRootDirectory' => $providerRootDirectory, 'providerSilentMode' => $providerSilentMode, 'specification' => $specification, + 'buildSpecification' => $specification, + 'runtimeSpecification' => $specification, 'search' => implode(' ', [$functionId, $name, $runtime]), ]))); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php index 3de0322d6e..e752e97494 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php @@ -253,6 +253,7 @@ class Create extends Action 'resourceId' => $site->getId(), 'resourceType' => 'sites', 'buildCommands' => \implode(' && ', $commands), + 'startCommand' => $site->getAttribute('startCommand', ''), 'buildOutput' => $outputDirectory, 'adapter' => $site->getAttribute('adapter', ''), 'fallbackFile' => $site->getAttribute('fallbackFile', ''), @@ -320,6 +321,7 @@ class Create extends Action 'resourceId' => $site->getId(), 'resourceType' => 'sites', 'buildCommands' => \implode(' && ', $commands), + 'startCommand' => $site->getAttribute('startCommand', ''), 'buildOutput' => $outputDirectory, 'adapter' => $site->getAttribute('adapter', ''), 'fallbackFile' => $site->getAttribute('fallbackFile', ''), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php index 9554e2aa14..5656eb09ab 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php @@ -119,6 +119,7 @@ class Create extends Action 'sourcePath' => $destination, 'totalSize' => $deployment->getAttribute('sourceSize', 0), 'buildCommands' => \implode(' && ', $commands), + 'startCommand' => $site->getAttribute('startCommand', ''), 'buildOutput' => $site->getAttribute('outputDirectory', ''), 'adapter' => $site->getAttribute('adapter', ''), 'fallbackFile' => $site->getAttribute('fallbackFile', ''), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php index 30d5e779c1..aa78061057 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php @@ -166,6 +166,7 @@ class Create extends Base 'resourceInternalId' => $site->getSequence(), 'resourceType' => 'sites', 'buildCommands' => \implode(' && ', $commands), + 'startCommand' => $site->getAttribute('startCommand', ''), 'buildOutput' => $site->getAttribute('outputDirectory', ''), 'providerRepositoryName' => $repository, 'providerRepositoryOwner' => $owner, diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php index 76a11ff736..b48cfeb73f 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php @@ -150,6 +150,8 @@ class Create extends Base 'timeout' => $timeout, 'installCommand' => $installCommand, 'buildCommand' => $buildCommand, + 'deploymentRetention' => 0, + 'startCommand' => '', 'outputDirectory' => $outputDirectory, 'search' => implode(' ', [$siteId, $name, $framework]), 'fallbackFile' => $fallbackFile, @@ -162,6 +164,8 @@ class Create extends Base 'providerRootDirectory' => $providerRootDirectory, 'providerSilentMode' => $providerSilentMode, 'specification' => $specification, + 'buildSpecification' => $specification, + 'runtimeSpecification' => $specification, 'buildRuntime' => $buildRuntime, 'adapter' => $adapter, ])); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index 8c48aff586..b4b720537d 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -254,6 +254,8 @@ class Update extends Base 'timeout' => $timeout, 'installCommand' => $installCommand, 'buildCommand' => $buildCommand, + 'deploymentRetention' => 0, + 'startCommand' => '', 'outputDirectory' => $outputDirectory, 'installationId' => $installation->getId(), 'installationInternalId' => $installation->getSequence(), @@ -264,6 +266,8 @@ class Update extends Base 'providerRootDirectory' => $providerRootDirectory, 'providerSilentMode' => $providerSilentMode, 'specification' => $specification, + 'buildSpecification' => $specification, + 'runtimeSpecification' => $specification, 'search' => implode(' ', [$siteId, $name, $framework]), 'buildRuntime' => $buildRuntime, 'adapter' => $adapter, From d56a3c1534fe05fade001bcb874f7cfb463b0663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 16 Jan 2026 14:53:05 +0100 Subject: [PATCH 2/2] Apply suggestion from @Meldiron --- .../Platform/Modules/Functions/Http/Functions/Update.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php index f2925f52be..f73e7ed8b8 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php @@ -262,6 +262,7 @@ class Update extends Base 'commands' => $commands, 'scopes' => $scopes, 'deploymentRetention' => 0, + 'startCommand' => '', 'installationId' => $installation->getId(), 'installationInternalId' => $installation->getSequence(), 'providerRepositoryId' => $providerRepositoryId,