Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
226 changes: 226 additions & 0 deletions src/Migration/Destinations/Appwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

use Appwrite\AppwriteException;
use Appwrite\Client;
use Appwrite\Enums\Adapter;
use Appwrite\Enums\BuildRuntime;
use Appwrite\Enums\Compression;
use Appwrite\Enums\Framework;
use Appwrite\Enums\PasswordHash;
use Appwrite\Enums\Runtime;
use Appwrite\InputFile;
use Appwrite\Services\Functions;
use Appwrite\Services\Sites;
use Appwrite\Services\Storage;
use Appwrite\Services\Teams;
use Appwrite\Services\Users;
Expand Down Expand Up @@ -42,6 +46,9 @@
use Utopia\Migration\Resources\Functions\Deployment;
use Utopia\Migration\Resources\Functions\EnvVar;
use Utopia\Migration\Resources\Functions\Func;
use Utopia\Migration\Resources\Sites\Deployment as SiteDeployment;
use Utopia\Migration\Resources\Sites\EnvVar as SiteEnvVar;
use Utopia\Migration\Resources\Sites\Site;
use Utopia\Migration\Resources\Storage\Bucket;
use Utopia\Migration\Resources\Storage\File;
use Utopia\Migration\Transfer;
Expand All @@ -54,6 +61,7 @@ class Appwrite extends Destination
protected string $key;

private Functions $functions;
private Sites $sites;
private Storage $storage;
private Teams $teams;
private Users $users;
Expand Down Expand Up @@ -87,6 +95,7 @@ public function __construct(
->setKey($key);

$this->functions = new Functions($this->client);
$this->sites = new Sites($this->client);
$this->storage = new Storage($this->client);
$this->teams = new Teams($this->client);
$this->users = new Users($this->client);
Expand Down Expand Up @@ -128,6 +137,11 @@ public static function getSupportedResources(): array
Resource::TYPE_FUNCTION,
Resource::TYPE_DEPLOYMENT,
Resource::TYPE_ENVIRONMENT_VARIABLE,

// Sites
Resource::TYPE_SITE,
Resource::TYPE_SITE_DEPLOYMENT,
Resource::TYPE_SITE_VARIABLE,
];
}

Expand Down Expand Up @@ -199,6 +213,15 @@ public function report(array $resources = [], array $resourceIds = []): array
$this->functions->create('', '', Runtime::NODE180());
}

// Sites
if (\in_array(Resource::TYPE_SITE, $resources)) {
$scope = 'sites.read';
$this->sites->list();

$scope = 'sites.write';
$this->sites->create('', '', Framework::OTHER(), BuildRuntime::STATIC1());
}

} catch (AppwriteException $e) {
if ($e->getCode() === 403) {
throw new \Exception('Missing scope: ' . $scope, previous: $e);
Expand Down Expand Up @@ -236,6 +259,7 @@ protected function import(array $resources, callable $callback): void
Transfer::GROUP_STORAGE => $this->importFileResource($resource),
Transfer::GROUP_AUTH => $this->importAuthResource($resource),
Transfer::GROUP_FUNCTIONS => $this->importFunctionResource($resource),
Transfer::GROUP_SITES => $this->importSiteResource($resource),
default => throw new \Exception('Invalid resource group'),
};
} catch (\Throwable $e) {
Expand Down Expand Up @@ -1505,4 +1529,206 @@ private function importDeployment(Deployment $deployment): Resource

return $deployment;
}

/**
* @throws AppwriteException
*/
public function importSiteResource(Resource $resource): Resource
{
switch ($resource->getName()) {
case Resource::TYPE_SITE:
/** @var Site $resource */

$buildRuntime = match ($resource->getBuildRuntime()) {
'node-14.5' => BuildRuntime::NODE145(),
'node-16.0' => BuildRuntime::NODE160(),
'node-18.0' => BuildRuntime::NODE180(),
'node-19.0' => BuildRuntime::NODE190(),
'node-20.0' => BuildRuntime::NODE200(),
'node-21.0' => BuildRuntime::NODE210(),
'node-22' => BuildRuntime::NODE22(),
'php-8.0' => BuildRuntime::PHP80(),
'php-8.1' => BuildRuntime::PHP81(),
'php-8.2' => BuildRuntime::PHP82(),
'php-8.3' => BuildRuntime::PHP83(),
'ruby-3.0' => BuildRuntime::RUBY30(),
'ruby-3.1' => BuildRuntime::RUBY31(),
'ruby-3.2' => BuildRuntime::RUBY32(),
'ruby-3.3' => BuildRuntime::RUBY33(),
'python-3.8' => BuildRuntime::PYTHON38(),
'python-3.9' => BuildRuntime::PYTHON39(),
'python-3.10' => BuildRuntime::PYTHON310(),
'python-3.11' => BuildRuntime::PYTHON311(),
'python-3.12' => BuildRuntime::PYTHON312(),
'python-ml-3.11' => BuildRuntime::PYTHONML311(),
'python-ml-3.12' => BuildRuntime::PYTHONML312(),
'dart-3.0' => BuildRuntime::DART30(),
'dart-3.1' => BuildRuntime::DART31(),
'dart-3.3' => BuildRuntime::DART33(),
'dart-3.5' => BuildRuntime::DART35(),
'dart-3.8' => BuildRuntime::DART38(),
'dart-3.9' => BuildRuntime::DART39(),
'dart-2.15' => BuildRuntime::DART215(),
'dart-2.16' => BuildRuntime::DART216(),
'dart-2.17' => BuildRuntime::DART217(),
'dart-2.18' => BuildRuntime::DART218(),
'dart-2.19' => BuildRuntime::DART219(),
'deno-1.21' => BuildRuntime::DENO121(),
'deno-1.24' => BuildRuntime::DENO124(),
'deno-1.35' => BuildRuntime::DENO135(),
'deno-1.40' => BuildRuntime::DENO140(),
'deno-1.46' => BuildRuntime::DENO146(),
'deno-2.0' => BuildRuntime::DENO20(),
'dotnet-6.0' => BuildRuntime::DOTNET60(),
'dotnet-7.0' => BuildRuntime::DOTNET70(),
'dotnet-8.0' => BuildRuntime::DOTNET80(),
'java-8.0' => BuildRuntime::JAVA80(),
'java-11.0' => BuildRuntime::JAVA110(),
'java-17.0' => BuildRuntime::JAVA170(),
'java-18.0' => BuildRuntime::JAVA180(),
'java-21.0' => BuildRuntime::JAVA210(),
'java-22' => BuildRuntime::JAVA22(),
'swift-5.5' => BuildRuntime::SWIFT55(),
'swift-5.8' => BuildRuntime::SWIFT58(),
'swift-5.9' => BuildRuntime::SWIFT59(),
'swift-5.10' => BuildRuntime::SWIFT510(),
'kotlin-1.6' => BuildRuntime::KOTLIN16(),
'kotlin-1.8' => BuildRuntime::KOTLIN18(),
'kotlin-1.9' => BuildRuntime::KOTLIN19(),
'kotlin-2.0' => BuildRuntime::KOTLIN20(),
'cpp-17' => BuildRuntime::CPP17(),
'cpp-20' => BuildRuntime::CPP20(),
'bun-1.0' => BuildRuntime::BUN10(),
'bun-1.1' => BuildRuntime::BUN11(),
'go-1.23' => BuildRuntime::GO123(),
'static-1' => BuildRuntime::STATIC1(),
'flutter-3.24' => BuildRuntime::FLUTTER324(),
'flutter-3.27' => BuildRuntime::FLUTTER327(),
'flutter-3.29' => BuildRuntime::FLUTTER329(),
'flutter-3.32' => BuildRuntime::FLUTTER332(),
'flutter-3.35' => BuildRuntime::FLUTTER335(),
default => throw new \Exception('Invalid Build Runtime: ' . $resource->getBuildRuntime()),
};

$framework = match ($resource->getFramework()) {
'analog' => Framework::ANALOG(),
'angular' => Framework::ANGULAR(),
'astro' => Framework::ASTRO(),
'flutter', 'flutter-web' => Framework::FLUTTER(),
'lynx' => Framework::LYNX(),
'nextjs' => Framework::NEXTJS(),
'nuxt' => Framework::NUXT(),
'react' => Framework::REACT(),
'react-native' => Framework::REACTNATIVE(),
'remix' => Framework::REMIX(),
'svelte-kit' => Framework::SVELTEKIT(),
'tanstack-start' => Framework::TANSTACKSTART(),
'vite' => Framework::VITE(),
'vue' => Framework::VUE(),
default => Framework::OTHER(),
};

$adapter = match ($resource->getAdapter()) {
'static' => Adapter::STATIC(),
'ssr' => Adapter::SSR(),
default => null,
};
Comment on lines +1542 to +1635
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Appwrite PHP SDK v19.0.0 Framework enum

💡 Result:

In Appwrite PHP SDK 19.0.0 (tagged Dec 2, 2025) the Sites service’s framework parameter is typed using the Framework enum (namespace Appwrite\Enums). (github.com)

Usage pattern (as shown in the PHP Sites API docs):

use Appwrite\Enums\Framework;

$sites->update(
  siteId: '<SITE_ID>',
  name: '<NAME>',
  framework: Framework::ANALOG(),
);

(appwrite.io)

The enum values correspond to the frameworks Appwrite Sites supports (and “Other”), e.g. Next.js, Nuxt, SvelteKit, Angular, Astro, Remix, TanStack Start, Flutter Web, React Native, Other JavaScript. (appwrite.io)

Citations:


🌐 Web query:

Appwrite PHP SDK v19.0.0 BuildRuntime enum Flutter

💡 Result:

  • Appwrite PHP SDK v19.0.0 exists as the Composer package appwrite/appwrite (with newer versions available, e.g. 19.1.0). [1]
  • “buildRuntime” is a Sites build setting (server-side / Console + Sites API), not a Flutter SDK concept. Appwrite’s Flutter Web Sites flow is driven by selecting Framework = “Flutter Web” and using the default Flutter build commands/output (e.g., flutter pub get, flutter build web ..., output ./build/web). [2]
  • If you’re trying to create a Flutter Web Site via API/SDK and you’re seeing “missing buildRuntime”, that error has been reported by users for Flutter Sites creation in the Console. [3] Appwrite later noted they “updated Flutter default build runtime” in the Appwrite 1.8.1 self-hosted release notes/changelog, so upgrading your Appwrite server may be relevant. [4]

If you share the exact PHP call you’re making (which Sites API method + parameters), I can tell you what field maps to buildRuntime and what values your SDK exposes for it.

Sources: [1] Packagist appwrite/appwrite (PHP SDK versions) • [2] Appwrite Docs: Deploy a Flutter Web app to Sites • [3] Appwrite Thread: “missing buildRuntime” for Flutter Sites • [4] Appwrite changelog: Appwrite 1.8.1 (“Updated Flutter default build runtime”)


🏁 Script executed:

# Check composer.json or other dependency files to see which Appwrite SDK version is specified
find . -name "composer.json" -o -name "composer.lock" | head -5

Repository: utopia-php/migration

Length of output: 95


🏁 Script executed:

cat ./composer.json | grep -A 10 "require"

Repository: utopia-php/migration

Length of output: 639


🌐 Web query:

Appwrite PHP SDK v19.0.0 GitHub Framework enum class definition REACTNATIVE TANSTACKSTART

💡 Result:

In Appwrite PHP SDK 19.0.0, there is no Framework enum class in the repo (so you won’t find enum values like REACTNATIVE or TANSTACKSTART there). The 19.0.0 code at commit b0a3ffd shows only these enums under src/Appwrite/Enums: BuildRuntime, Runtime, TemplateReferenceType, VCSReferenceType. [1]

Also, the Sites PHP API reference shows use Appwrite\Enums\; and framework: ::ANALOG() (i.e., the docs intend an enum usage), but it doesn’t correspond to an actual Framework enum shipped in PHP SDK 19.0.0. [2]

If you’re trying to select React Native or TanStack Start as an Appwrite Sites “framework”, that’s a Sites feature/framework key, and TanStack Start support is documented on the Sites side (not via a PHP SDK enum in 19.0.0). [3]

Sources:
[1] appwrite/sdk-for-php@b0a3ffd
[2] https://appwrite.io/docs/references/cloud/server-php/sites
[3] https://appwrite.io/changelog/entry/2025-10-28


🌐 Web query:

Appwrite PHP SDK v19.0.0 GitHub BuildRuntime enum FLUTTER methods

💡 Result:

Appwrite PHP SDK 19.0.0 is a real tagged release (published Dec 3, 2025) in appwrite/sdk-for-php. In its GitHub release notes, 19.0.0 mentions enum/service changes like renaming VCSDeploymentTypeVCSReferenceType, changing createTemplateDeployment parameters, and adding Theme, Timezone, and Output enums—but it does not mention BuildRuntime specifically. [1]

Packagist also lists appwrite/appwrite version 19.0.0 (same codebase as appwrite/sdk-for-php). [2]

If you’re trying to find the BuildRuntime enum’s Flutter-related entries/methods in v19.0.0, the authoritative place is the SDK source at tag 19.0.0, typically under something like src/Appwrite/Enums/BuildRuntime.php in the repo. [3]

Sources
[1] https://github.com/appwrite/sdk-for-php/releases (see “19.0.0”)
[2] https://packagist.org/packages/appwrite/appwrite
[3] https://github.com/appwrite/sdk-for-php/tree/19.0.0


🌐 Web query:

Appwrite PHP SDK v19.0.0 BuildRuntime enum source code methods

💡 Result:

In Appwrite PHP SDK 19.0.0 (composer package appwrite/appwrite), the BuildRuntime enum lives at:

  • src/Appwrite/Enums/BuildRuntime.php (github.com)

Because it’s an auto-generated “enum class” (not a native PHP 8.1 enum), its “enum values” are exposed as static methods on the class (e.g. BuildRuntime::SOME_RUNTIME() returning a string value).

How to get the exact method list (from the v19.0.0 source you have installed)

  1. Install the exact version:
composer require appwrite/appwrite:19.0.0
  1. Open:
vendor/appwrite/appwrite/src/Appwrite/Enums/BuildRuntime.php

Or, from your project root:

sed -n '1,200p' vendor/appwrite/appwrite/src/Appwrite/Enums/BuildRuntime.php

That file is the source of truth for the complete list of BuildRuntime::...() methods in v19.0.0. (github.com)

Citations:


🌐 Web query:

Appwrite PHP SDK Framework enum when introduced first version

💡 Result:

Appwrite’s Enum support (the SDK feature that adds enum/enum-like types) was announced on Feb 28, 2024. [1]

For the Appwrite PHP SDK, enum support was first shipped in v17.2.0, released on Oct 3, 2025 (“introduces support of enums in response models”). [2]

So, the first PHP SDK version where a Framework enum (or any other newly generated enums) could appear is: 17.2.0. [2]

Sources:
[1] https://appwrite.io/changelog/entry/2024-02-28
[2] https://github.com/appwrite/sdk-for-php/releases/tag/17.2.0


🏁 Script executed:

# Check if there's any reference to these enums in the codebase or imports
rg "use Appwrite.*Framework|use Appwrite.*BuildRuntime|use Appwrite.*Adapter" --type php

Repository: utopia-php/migration

Length of output: 274


🌐 Web query:

Appwrite PHP SDK v19.1.0 Framework enum

💡 Result:

In Appwrite PHP SDK 19.1.0 (appwrite/appwrite on Packagist), there is no Framework enum shipped with the SDK. [1]

Appwrite’s official SDK docs list the enums that are generated/available (OAuth providers, authenticator types, browsers, index types, image format/gravity, function runtime, etc.), and “Framework” is not one of them. [2]

So if you’re looking for a “framework” parameter (e.g., laravel, symfony, etc.), you’ll need to pass it as a plain string (if a specific API expects it) or define your own enum/constants in your app.

Sources:
[1] https://packagist.org/packages/appwrite/appwrite
[2] https://appwrite.io/docs/sdks


🌐 Web query:

Appwrite PHP SDK latest version Framework enum Adapter enum

💡 Result:

  • Latest Appwrite PHP SDK version (Composer package appwrite/appwrite): 19.1.0 (released 2025-12-18). (packagist.org)
  • Framework enum (PHP SDK): Appwrite\Enums\Framework (used for Sites framework: like Framework::ANALOG()). (appwrite.io)
  • Adapter enum (PHP SDK): Appwrite\Enums\Adapter (used for Sites adapter: like Adapter::STATIC()). Allowed adapter values are static and ssr (enum helpers: Adapter::STATIC() / Adapter::SSR()). (appwrite.io)

Example (from Sites API docs, PHP):

use Appwrite\Enums\Framework;
use Appwrite\Enums\Adapter;

framework: Framework::ANALOG(),
adapter: Adapter::STATIC(),

(appwrite.io)

Citations:


🏁 Script executed:

# Try to read BuildRuntime enum if it exists in vendor
if [ -f "vendor/appwrite/appwrite/src/Appwrite/Enums/BuildRuntime.php" ]; then
  head -100 vendor/appwrite/appwrite/src/Appwrite/Enums/BuildRuntime.php
else
  echo "BuildRuntime.php not found - may need to install dependencies"
fi

Repository: utopia-php/migration

Length of output: 125


🏁 Script executed:

# Check what version is actually installed
composer show appwrite/appwrite 2>/dev/null | head -5

Repository: utopia-php/migration

Length of output: 46


🌐 Web query:

site:github.com appwrite/sdk-for-php Framework enum class

💡 Result:

In appwrite/sdk-for-php there is no Framework enum/class (i.e., no Appwrite\Enums\Framework).

Appwrite’s docs list the SDK enum types that are generated/provided (authenticator type/name, OAuth provider, browsers, credit cards, image gravity/format, relationship types, SMTP encryption, function runtime, messaging provider type, compression algorithms, execution methods, country flags, etc.), and “framework” is not one of them. [1]

Source: appwrite/sdk-for-php is the official PHP SDK repo referenced by Appwrite/Packagist. [2]

References:
[1] (appwrite.io)
[2] (packagist.org)

Citations:


🌐 Web query:

site:github.com appwrite/sdk-for-php/releases Framework enum Sites support

💡 Result:

As of the latest Appwrite PHP SDK release (19.1.0, Dec 18, 2025), the release notes don’t mention adding any Sites “Framework” enum (or updating enums for Sites framework selection) — the only listed change is about creating columns/indexes synchronously when creating a table. (github.com)

Also, Appwrite’s SDK documentation lists the kinds of enums the SDKs provide (auth providers, runtimes, etc.) and does not list a Sites “Framework” enum. (appwrite.io)

If you’re looking for the supported Appwrite Sites frameworks (Next.js, Nuxt, SvelteKit, etc.), they’re documented in the Sites “Frameworks” page. (appwrite.io)

Citations:


🏁 Script executed:

# Check the actual file in the repo to see what enums are being used
head -50 src/Migration/Destinations/Appwrite.php | grep -A 5 -B 5 "Framework\|BuildRuntime\|Adapter"

Repository: utopia-php/migration

Length of output: 429


🌐 Web query:

site:github.com/appwrite/sdk-for-php "class Framework" enums

💡 Result:

A web search for site:github.com/appwrite/sdk-for-php "class Framework" doesn’t turn up any matches in the appwrite/sdk-for-php repository (it’s also marked read-only). [1]

However, Appwrite’s Sites PHP API reference shows that the PHP SDK does expose a framework enum-like type as Appwrite\Enums\Framework, used like Framework::ANALOG() when creating/updating a Site. [2]


🌐 Web query:

Appwrite PHP SDK when will Framework enum be added Sites API

💡 Result:

As of the latest released Appwrite PHP SDK on Packagist (appwrite/appwrite 19.1.0, released Dec 18, 2025), the Sites API “framework” enum (e.g., Framework::ANALOG) is not yet available in the PHP SDK (the PHP Sites docs still show blank enum imports like use Appwrite\Enums\; for framework). [1] [2]

There’s currently an open PR in appwrite/sdk-for-php#57 “Updates: sync as per latest cloud specs” (opened Jan 14, 2026) — which is the likely vehicle for adding missing/updated spec items like the Sites framework enum, but no ETA is published; it will land when that PR is merged and a new PHP SDK release is cut. [3]

Workaround until then: pass the framework value as the raw string expected by the API (e.g., "analog") instead of an enum. [2]

Sources:
[1] https://packagist.org/packages/appwrite/appwrite (release info + repo link)
[2] https://appwrite.io/docs/references/cloud/server-php/sites (PHP Sites API reference showing missing enum import)
[3] https://github.com/appwrite/sdk-for-php/pulls (shows PR #57 opened Jan 14, 2026)


Remove Framework enum usage or constrain SDK version to post-Framework support release.

The Framework enum (Appwrite\Enums\Framework) does not exist in Appwrite PHP SDK v19.0.0 or v19.1.0. The import statement will cause a fatal "Class not found" error, preventing the entire migration class from loading. The Appwrite PHP SDK team is working to add Sites framework enum support (PR #57, opened Jan 14, 2026), but no release with this enum is currently available.

Either:

  1. Remove the Framework enum and pass framework as a string (e.g., 'analog', 'flutter', 'react') until the SDK adds the enum.
  2. Constrain the SDK dependency to a future version that includes the Framework enum (once released and documented).

The same validation should apply to Adapter and BuildRuntime enums to ensure they are fully supported in the installed SDK version before use.

🤖 Prompt for AI Agents
In `@src/Migration/Destinations/Appwrite.php` around lines 1542 - 1635, The code
uses Appwrite enums (Framework, Adapter, BuildRuntime) that may not exist in the
installed SDK and will throw fatal errors; replace enum usage in the match
blocks (the mappings that assign $framework, $adapter, $buildRuntime from
$resource->getFramework()/getAdapter()/getBuildRuntime()) with plain string
values (or a validated string mapping) instead of Framework::*, Adapter::*,
BuildRuntime::* calls, or alternatively add a runtime guard (class_exists for
each enum) and fallback to the raw string when the enum class is missing; update
the match blocks in src/Migration/Destinations/Appwrite.php (the $framework,
$adapter, $buildRuntime assignments) to return strings (e.g., 'react', 'static',
'node-18.0') or use a safe mapping and remove direct enum references unless the
SDK dependency is constrained to a release that includes those enum classes.


$this->sites->create(
$resource->getId(),
$resource->getSiteName(),
$framework,
$buildRuntime,
$resource->getEnabled(),
$resource->getLogging(),
$resource->getTimeout(),
$resource->getInstallCommand(),
$resource->getBuildCommand(),
$resource->getOutputDirectory(),
$adapter,
fallbackFile: $resource->getFallbackFile(),
specification: $resource->getSpecification(),
);
break;
case Resource::TYPE_SITE_VARIABLE:
/** @var SiteEnvVar $resource */
$this->sites->createVariable(
$resource->getSite()->getId(),
$resource->getKey(),
$resource->getValue(),
$resource->getSecret()
);
break;
case Resource::TYPE_SITE_DEPLOYMENT:
/** @var SiteDeployment $resource */
return $this->importSiteDeployment($resource);
}

$resource->setStatus(Resource::STATUS_SUCCESS);

return $resource;
}

/**
* @throws AppwriteException
* @throws \Exception
*/
private function importSiteDeployment(SiteDeployment $deployment): Resource
{
$siteId = $deployment->getSite()->getId();

if ($deployment->getSize() <= Transfer::STORAGE_MAX_CHUNK_SIZE) {
$response = $this->client->call(
'POST',
"/sites/{$siteId}/deployments",
[
'content-type' => 'multipart/form-data',
],
[
'siteId' => $siteId,
'code' => new \CURLFile('data://application/gzip;base64,' . base64_encode($deployment->getData()), 'application/gzip', 'deployment.tar.gz'),
'activate' => $deployment->getActivated(),
]
);

if (!\is_array($response) || !isset($response['$id'])) {
throw new \Exception('Site deployment creation failed');
}

$deployment->setStatus(Resource::STATUS_SUCCESS);

return $deployment;
}

$response = $this->client->call(
'POST',
"/sites/{$siteId}/deployments",
[
'content-type' => 'multipart/form-data',
'content-range' => 'bytes ' . ($deployment->getStart()) . '-' . ($deployment->getEnd() == ($deployment->getSize() - 1) ? $deployment->getSize() : $deployment->getEnd()) . '/' . $deployment->getSize(),
'x-appwrite-id' => $deployment->getId(),
],
[
'siteId' => $siteId,
'code' => new \CURLFile('data://application/gzip;base64,' . base64_encode($deployment->getData()), 'application/gzip', 'deployment.tar.gz'),
'activate' => $deployment->getActivated(),
]
);

if (!\is_array($response) || !isset($response['$id'])) {
throw new \Exception('Site deployment creation failed');
}

if ($deployment->getStart() === 0) {
$deployment->setId($response['$id']);
}

if ($deployment->getEnd() == ($deployment->getSize() - 1)) {
$deployment->setStatus(Resource::STATUS_SUCCESS);
} else {
$deployment->setStatus(Resource::STATUS_PENDING);
}

return $deployment;
}
}
9 changes: 9 additions & 0 deletions src/Migration/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ abstract class Resource implements \JsonSerializable

public const TYPE_FUNCTION = 'function';

public const TYPE_SITE = 'site';

public const TYPE_INDEX = 'index';

// Children (Resources that are created by other resources)
Expand All @@ -50,6 +52,10 @@ abstract class Resource implements \JsonSerializable

public const TYPE_DEPLOYMENT = 'deployment';

public const TYPE_SITE_DEPLOYMENT = 'site-deployment';

public const TYPE_SITE_VARIABLE = 'site-variable';

public const TYPE_HASH = 'hash';

public const TYPE_ENVIRONMENT_VARIABLE = 'environment-variable';
Expand All @@ -74,6 +80,9 @@ abstract class Resource implements \JsonSerializable
self::TYPE_FILE,
self::TYPE_FUNCTION,
self::TYPE_DEPLOYMENT,
self::TYPE_SITE,
self::TYPE_SITE_DEPLOYMENT,
self::TYPE_SITE_VARIABLE,
self::TYPE_HASH,
self::TYPE_INDEX,
self::TYPE_USER,
Expand Down
Loading