Merge pull request #6167 from appwrite/fix-migration-issues

fix: migration issues
This commit is contained in:
Christy Jacob 2023-09-07 02:06:48 -04:00 committed by GitHub
commit e27f705179
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 167 additions and 94 deletions

2
.env
View file

@ -71,7 +71,7 @@ _APP_FUNCTIONS_MAINTENANCE_INTERVAL=600
_APP_FUNCTIONS_RUNTIMES_NETWORK=runtimes
_APP_EXECUTOR_SECRET=your-secret-key
_APP_EXECUTOR_HOST=http://proxy/v1
_APP_FUNCTIONS_RUNTIMES=
_APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1
_APP_MAINTENANCE_INTERVAL=86400
_APP_MAINTENANCE_RETENTION_CACHE=2592000
_APP_MAINTENANCE_RETENTION_EXECUTION=1209600

View file

@ -2,25 +2,24 @@
## Fixes
## Changes
- Fix create phone session abuse key [#6134][https://github.com/appwrite/appwrite/pull/6134]
- Fix CLI backwards compatibility [#6125](https://github.com/appwrite/appwrite/pull/6125)
* Fix Not Found error when deploying function from git [#6133](https://github.com/appwrite/appwrite/pull/6133)
* Fix _APP_EXECUTOR_HOST for upgrades [#6141](https://github.com/appwrite/appwrite/pull/6141)
* Fix create execution request filter from previous SDK version [#6146](https://github.com/appwrite/appwrite/pull/6146)
* Fix migrations worker [#6116](https://github.com/appwrite/appwrite/pull/6116)
* Fix: Global variables by [#6150](https://github.com/appwrite/appwrite/pull/6150)
* Fix webhook secret validation and executor path validation [#6162](https://github.com/appwrite/appwrite/pull/6162)
* Fix: Untrusted custom domains + auto-ssl [#6155](https://github.com/appwrite/appwrite/pull/6155)
* Fix: AI Assistant [#6153](https://github.com/appwrite/appwrite/pull/6153)
* Fix create phone session abuse key by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6134
* Fix CLI backwards compatibility by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6125
* Override forEachDocument() to skip the cache collection by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6144
* Fix Not Found error when deploying function from git by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6133
* Add required params for scheduled functions by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6148
* Update the error message for router_domain_not_configured by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6145
* Fix _APP_EXECUTOR_HOST for upgrades by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6141
* Change executor hostname back to appwrite-executor by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6160
* Fix create execution request filter from previous SDK version by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6146
* Fix: AI Assistant by @Meldiron in https://github.com/appwrite/appwrite/pull/6153
* Make URL optional for Create Membership API and Serverside Requests by @PineappleIOnic in https://github.com/appwrite/appwrite/pull/6157
* Fix: v2 functions by @Meldiron in https://github.com/appwrite/appwrite/pull/6142
* Fix migrations worker by @abnegate in https://github.com/appwrite/appwrite/pull/6116
* Fix: Global variables by @Meldiron in https://github.com/appwrite/appwrite/pull/6150
* Fix webhook secret validation and executor path validation by @vermakhushboo in https://github.com/appwrite/appwrite/pull/6162
* Fix: Untrusted custom domains + auto-ssl by @Meldiron in https://github.com/appwrite/appwrite/pull/6155
* Update composer.lock by @PineappleIOnic in https://github.com/appwrite/appwrite/pull/6161
## Changes
* Add required params for scheduled functions [#6148](https://github.com/appwrite/appwrite/pull/6148)
* Update the error message for router_domain_not_configured [#6145](https://github.com/appwrite/appwrite/pull/6145)
* Override forEachDocument() to skip the cache collection [#6144](https://github.com/appwrite/appwrite/pull/6144)
* Support for v2 functions [#6142](https://github.com/appwrite/appwrite/pull/6142)
* Change executor hostname back to appwrite-executor [#6160](https://github.com/appwrite/appwrite/pull/6160)
* Make URL optional for Create Membership API and Serverside Requests [#6157](https://github.com/appwrite/appwrite/pull/6157)
# Version 1.4.1

View file

@ -3,6 +3,7 @@
use Appwrite\Auth\Auth;
$member = [
'global',
'public',
'home',
'console',
@ -24,6 +25,7 @@ $member = [
];
$admins = [
'global',
'graphql',
'teams.read',
'teams.write',

View file

@ -814,7 +814,7 @@ include_once __DIR__ . '/shared/api/auth.php';
App::wildcard()
->groups(['api'])
->label('scope', 'public')
->label('scope', 'global')
->action(function () {
throw new AppwriteException(AppwriteException::GENERAL_ROUTE_NOT_FOUND);
});

View file

@ -49,7 +49,7 @@
"utopia-php/cache": "0.8.*",
"utopia-php/cli": "0.15.*",
"utopia-php/config": "0.2.*",
"utopia-php/database": "0.43.*",
"utopia-php/database": "0.43.0",
"utopia-php/domains": "0.3.*",
"utopia-php/dsn": "0.1.*",
"utopia-php/framework": "0.31.0",

153
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "bc47430e5cb3430f354b4eee6fd8c9c7",
"content-hash": "d165291f1be92644ba081f9c39050602",
"packages": [
{
"name": "adhocore/jwt",
@ -386,6 +386,79 @@
},
"time": "2023-04-18T15:34:23+00:00"
},
{
"name": "composer/package-versions-deprecated",
"version": "1.11.99.5",
"source": {
"type": "git",
"url": "https://github.com/composer/package-versions-deprecated.git",
"reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b4f54f74ef3453349c24a845d22392cd31e65f1d",
"reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.1.0 || ^2.0",
"php": "^7 || ^8"
},
"replace": {
"ocramius/package-versions": "1.11.99"
},
"require-dev": {
"composer/composer": "^1.9.3 || ^2.0@dev",
"ext-zip": "^1.13",
"phpunit/phpunit": "^6.5 || ^7"
},
"type": "composer-plugin",
"extra": {
"class": "PackageVersions\\Installer",
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"PackageVersions\\": "src/PackageVersions"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be"
}
],
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"support": {
"issues": "https://github.com/composer/package-versions-deprecated/issues",
"source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.5"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2022-01-17T14:14:24+00:00"
},
{
"name": "dragonmantank/cron-expression",
"version": "v3.3.2",
@ -841,28 +914,24 @@
},
{
"name": "jean85/pretty-package-versions",
"version": "2.0.5",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/Jean85/pretty-package-versions.git",
"reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af"
"reference": "1e0104b46f045868f11942aea058cd7186d6c303"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/ae547e455a3d8babd07b96966b17d7fd21d9c6af",
"reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af",
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/1e0104b46f045868f11942aea058cd7186d6c303",
"reference": "1e0104b46f045868f11942aea058cd7186d6c303",
"shasum": ""
},
"require": {
"composer-runtime-api": "^2.0.0",
"php": "^7.1|^8.0"
"composer/package-versions-deprecated": "^1.8.0",
"php": "^7.0|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.17",
"jean85/composer-provided-replaced-stub-package": "^1.0",
"phpstan/phpstan": "^0.12.66",
"phpunit/phpunit": "^7.5|^8.5|^9.4",
"vimeo/psalm": "^4.3"
"phpunit/phpunit": "^6.0|^8.5|^9.2"
},
"type": "library",
"extra": {
@ -885,7 +954,7 @@
"email": "alessandro.lai85@gmail.com"
}
],
"description": "A library to get pretty versions strings of installed dependencies",
"description": "A wrapper for ocramius/package-versions to get pretty versions strings",
"keywords": [
"composer",
"package",
@ -894,9 +963,9 @@
],
"support": {
"issues": "https://github.com/Jean85/pretty-package-versions/issues",
"source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.5"
"source": "https://github.com/Jean85/pretty-package-versions/tree/1.6.0"
},
"time": "2021-10-08T21:21:46+00:00"
"time": "2021-02-04T16:20:16+00:00"
},
{
"name": "laravel/pint",
@ -1119,35 +1188,34 @@
},
{
"name": "mongodb/mongodb",
"version": "1.10.0",
"version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/mongodb/mongo-php-library.git",
"reference": "b0bbd657f84219212487d01a8ffe93a789e1e488"
"reference": "953dbc19443aa9314c44b7217a16873347e6840d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/b0bbd657f84219212487d01a8ffe93a789e1e488",
"reference": "b0bbd657f84219212487d01a8ffe93a789e1e488",
"url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/953dbc19443aa9314c44b7217a16873347e6840d",
"reference": "953dbc19443aa9314c44b7217a16873347e6840d",
"shasum": ""
},
"require": {
"ext-hash": "*",
"ext-json": "*",
"ext-mongodb": "^1.11.0",
"jean85/pretty-package-versions": "^1.2 || ^2.0.1",
"php": "^7.1 || ^8.0",
"ext-mongodb": "^1.8.1",
"jean85/pretty-package-versions": "^1.2",
"php": "^7.0 || ^8.0",
"symfony/polyfill-php80": "^1.19"
},
"require-dev": {
"doctrine/coding-standard": "^9.0",
"squizlabs/php_codesniffer": "^3.6",
"symfony/phpunit-bridge": "^5.2"
"squizlabs/php_codesniffer": "^3.5, <3.5.5",
"symfony/phpunit-bridge": "5.x-dev"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.10.x-dev"
"dev-master": "1.8.x-dev"
}
},
"autoload": {
@ -1182,9 +1250,9 @@
],
"support": {
"issues": "https://github.com/mongodb/mongo-php-library/issues",
"source": "https://github.com/mongodb/mongo-php-library/tree/1.10.0"
"source": "https://github.com/mongodb/mongo-php-library/tree/1.8.0"
},
"time": "2021-10-20T22:22:37+00:00"
"time": "2020-11-25T12:26:02+00:00"
},
{
"name": "mustangostang/spyc",
@ -2152,16 +2220,16 @@
},
{
"name": "utopia-php/database",
"version": "0.43.1",
"version": "0.43.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "cc0247f4f0c402b39f663bf9f77b29d69b95f9d6"
"reference": "fb96fc6c94d5efcd43913c34bece62daba76a5e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/cc0247f4f0c402b39f663bf9f77b29d69b95f9d6",
"reference": "cc0247f4f0c402b39f663bf9f77b29d69b95f9d6",
"url": "https://api.github.com/repos/utopia-php/database/zipball/fb96fc6c94d5efcd43913c34bece62daba76a5e9",
"reference": "fb96fc6c94d5efcd43913c34bece62daba76a5e9",
"shasum": ""
},
"require": {
@ -2170,11 +2238,12 @@
"php": ">=8.0",
"utopia-php/cache": "0.8.*",
"utopia-php/framework": "0.*.*",
"utopia-php/mongo": "0.3.*"
"utopia-php/mongo": "0.2.*"
},
"require-dev": {
"fakerphp/faker": "^1.14",
"laravel/pint": "1.4.*",
"mongodb/mongodb": "1.8.0",
"pcov/clobber": "^2.0",
"phpstan/phpstan": "1.10.*",
"phpunit/phpunit": "^9.4",
@ -2202,9 +2271,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.43.1"
"source": "https://github.com/utopia-php/database/tree/0.43.0"
},
"time": "2023-09-01T20:38:36+00:00"
"time": "2023-08-29T10:18:39+00:00"
},
{
"name": "utopia-php/domains",
@ -2622,21 +2691,21 @@
},
{
"name": "utopia-php/mongo",
"version": "0.3.1",
"version": "0.2.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/mongo.git",
"reference": "52326a9a43e2d27ff0c15c48ba746dacbe9a7aee"
"reference": "b6dfb31b93c07c59b8bbd62a3b52e3b97a407c09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/mongo/zipball/52326a9a43e2d27ff0c15c48ba746dacbe9a7aee",
"reference": "52326a9a43e2d27ff0c15c48ba746dacbe9a7aee",
"url": "https://api.github.com/repos/utopia-php/mongo/zipball/b6dfb31b93c07c59b8bbd62a3b52e3b97a407c09",
"reference": "b6dfb31b93c07c59b8bbd62a3b52e3b97a407c09",
"shasum": ""
},
"require": {
"ext-mongodb": "*",
"mongodb/mongodb": "1.10.0",
"mongodb/mongodb": "1.8.0",
"php": ">=8.0"
},
"require-dev": {
@ -2676,9 +2745,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/mongo/issues",
"source": "https://github.com/utopia-php/mongo/tree/0.3.1"
"source": "https://github.com/utopia-php/mongo/tree/0.2.0"
},
"time": "2023-09-01T17:25:28+00:00"
"time": "2023-03-22T10:44:29+00:00"
},
{
"name": "utopia-php/orchestration",

View file

@ -714,6 +714,7 @@ services:
- OPR_EXECUTOR_ENV=$_APP_ENV
- OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES
- OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET
- OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v3
- OPR_EXECUTOR_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER
- OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG
- OPR_EXECUTOR_STORAGE_DEVICE=$_APP_STORAGE_DEVICE

View file

@ -56,15 +56,15 @@ class V19 extends Migration
if ($domain->getAttribute('verification', false)) {
$status = 'verified';
}
$projectId = $domain->getAttribute('projectId');
$projectInternalId = $domain->getAttribute('projectInternalId');
if (empty($projectId) || empty($projectInternalId)) {
Console::warning("Error migrating domain {$domain->getAttribute('domain')}: Missing projectId or projectInternalId");
continue;
}
$ruleDocument = new Document([
'projectId' => $domain->getAttribute('projectId'),
'projectInternalId' => $domain->getAttribute('projectInternalId'),
@ -75,7 +75,7 @@ class V19 extends Migration
'status' => $status,
'certificateId' => $domain->getAttribute('certificateId'),
]);
try {
$this->consoleDB->createDocument('rules', $ruleDocument);
} catch (\Throwable $th) {
@ -651,9 +651,9 @@ class V19 extends Migration
switch ($document->getCollection()) {
case 'attributes':
case 'indexes':
$status = $document->getAttribute('status', '');
$status = $document->getAttribute('status');
if ($status === 'failed') {
$document->setAttribute('error', 'Unknown problem');
$document->setAttribute('error', $document->getAttribute('error', 'Unknown problem'));
}
break;
case 'builds':
@ -663,10 +663,10 @@ class V19 extends Migration
$stdout = $document->getAttribute('stdout', '');
$stderr = $document->getAttribute('stderr', '');
$document->setAttribute('logs', $stdout . PHP_EOL . $stderr);
$document->setAttribute('logs', $document->getAttribute('logs', $stdout . PHP_EOL . $stderr));
break;
case 'databases':
$document->setAttribute('enabled', true);
$document->setAttribute('enabled', $document->getAttribute('enabled', true));
break;
case 'deployments':
$resourceId = $document->getAttribute('resourceId');
@ -680,9 +680,8 @@ class V19 extends Migration
}
$commands = $this->getFunctionCommands($function);
$document->setAttribute('commands', $commands);
$document->setAttribute('type', 'manual');
$document->setAttribute('commands', $document->getAttribute('commands', $commands));
$document->setAttribute('type', $document->getAttribute('type', 'manual'));
break;
case 'executions':
$functionId = $document->getAttribute('functionId');
@ -694,9 +693,9 @@ class V19 extends Migration
$document->setAttribute('deploymentInternalId', $deployment->getInternalId());
break;
case 'functions':
$document->setAttribute('live', true);
$document->setAttribute('logging', true);
$document->setAttribute('version', 'v2');
$document->setAttribute('live', $document->getAttribute('live', true));
$document->setAttribute('logging', $document->getAttribute('logging', true));
$document->setAttribute('version', $document->getAttribute('version', 'v2'));
$deploymentId = $document->getAttribute('deployment');
if (!empty($deploymentId)) {
@ -706,21 +705,24 @@ class V19 extends Migration
}
$commands = $this->getFunctionCommands($document);
$document->setAttribute('commands', $commands);
$document->setAttribute('commands', $document->getAttribute('commands', $commands));
$schedule = $this->consoleDB->createDocument('schedules', new Document([
'region' => App::getEnv('_APP_REGION', 'default'), // Todo replace with projects region
'resourceType' => 'function',
'resourceId' => $document->getId(),
'resourceInternalId' => $document->getInternalId(),
'resourceUpdatedAt' => DateTime::now(),
'projectId' => $this->project->getId(),
'schedule' => $document->getAttribute('schedule'),
'active' => !empty($document->getAttribute('schedule')) && !empty($document->getAttribute('deployment')),
]));
if (empty($document->getAttribute('scheduleId', null))) {
$schedule = $this->consoleDB->createDocument('schedules', new Document([
'region' => App::getEnv('_APP_REGION', 'default'), // Todo replace with projects region
'resourceType' => 'function',
'resourceId' => $document->getId(),
'resourceInternalId' => $document->getInternalId(),
'resourceUpdatedAt' => DateTime::now(),
'projectId' => $this->project->getId(),
'schedule' => $document->getAttribute('schedule'),
'active' => !empty($document->getAttribute('schedule')) && !empty($document->getAttribute('deployment')),
]));
$document->setAttribute('scheduleId', $schedule->getId());
$document->setAttribute('scheduleInternalId', $schedule->getInternalId());
}
$document->setAttribute('scheduleId', $schedule->getId());
$document->setAttribute('scheduleInternalId', $schedule->getInternalId());
break;
case 'projects':
$document->setAttribute('version', '1.4.0');
@ -728,13 +730,13 @@ class V19 extends Migration
$databases = Config::getParam('pools-database', []);
$database = $databases[0];
$document->setAttribute('database', $database);
$document->setAttribute('smtp', []);
$document->setAttribute('templates', []);
$document->setAttribute('database', $document->getAttribute('database', $database));
$document->setAttribute('smtp', $document->getAttribute('smtp', []));
$document->setAttribute('templates', $document->getAttribute('templates', []));
break;
case 'variables':
$document->setAttribute('resourceType', 'function');
$document->setAttribute('resourceType', $document->getAttribute('resourceType', 'function'));
break;
default:
break;