This commit is contained in:
Torsten Dittmann 2022-07-25 12:23:43 +02:00
commit 0df77a5a65
6 changed files with 81 additions and 68 deletions

View file

@ -180,7 +180,7 @@ return [
[
'key' => 'cli',
'name' => 'Command Line',
'version' => '0.18.1',
'version' => '0.18.3',
'url' => 'https://github.com/appwrite/sdk-for-cli',
'package' => 'https://www.npmjs.com/package/appwrite-cli',
'enabled' => true,

39
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": "380d806f7540199698d12a7abeb13534",
"content-hash": "677b1b47c8567f0b7b05645e2bbc7bc7",
"packages": [
{
"name": "adhocore/jwt",
@ -2051,16 +2051,16 @@
},
{
"name": "utopia-php/database",
"version": "0.18.7",
"version": "0.18.9",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e"
"reference": "227b3ca919149b7b0d6556c8effe9ee46ed081e6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/d542ee433f1a545d926ffaf707bdf952dc18a52e",
"reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e",
"url": "https://api.github.com/repos/utopia-php/database/zipball/227b3ca919149b7b0d6556c8effe9ee46ed081e6",
"reference": "227b3ca919149b7b0d6556c8effe9ee46ed081e6",
"shasum": ""
},
"require": {
@ -2109,9 +2109,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.18.7"
"source": "https://github.com/utopia-php/database/tree/0.18.9"
},
"time": "2022-07-11T10:20:33+00:00"
"time": "2022-07-19T09:42:53+00:00"
},
{
"name": "utopia-php/domains",
@ -2387,16 +2387,16 @@
},
{
"name": "utopia-php/orchestration",
"version": "dev-cli-lib-upgrade",
"version": "0.6.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/orchestration.git",
"reference": "06f2afef516aca900ddb483689ebe6f8e7037d28"
"reference": "94263976413871efb6b16157a7101a81df3b6d78"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/orchestration/zipball/06f2afef516aca900ddb483689ebe6f8e7037d28",
"reference": "06f2afef516aca900ddb483689ebe6f8e7037d28",
"url": "https://api.github.com/repos/utopia-php/orchestration/zipball/94263976413871efb6b16157a7101a81df3b6d78",
"reference": "94263976413871efb6b16157a7101a81df3b6d78",
"shasum": ""
},
"require": {
@ -2436,9 +2436,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/orchestration/issues",
"source": "https://github.com/utopia-php/orchestration/tree/cli-lib-upgrade"
"source": "https://github.com/utopia-php/orchestration/tree/0.6.0"
},
"time": "2022-07-13T14:55:12+00:00"
"time": "2022-07-13T16:47:18+00:00"
},
{
"name": "utopia-php/preloader",
@ -5346,18 +5346,9 @@
"time": "2022-05-17T05:48:52+00:00"
}
],
"aliases": [
{
"package": "utopia-php/orchestration",
"version": "dev-cli-lib-upgrade",
"alias": "0.4.1",
"alias_normalized": "0.4.1.0"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"utopia-php/orchestration": 20
},
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -41,14 +41,14 @@
i {
cursor: pointer;
position: absolute;
font-size: 14px;
line-height: 20px;
top: 9px;
.func-start(9px);
font-size: 12px;
line-height: 24px;
top: 8px;
.func-start(8px);
color: var(--config-color-background-dark);
background: var(--config-color-normal);
width: 22px;
height: 22px;
width: 24px;
height: 24px;
border-radius: 50%;
}

View file

@ -3,10 +3,11 @@
namespace Appwrite\Migration\Version;
use Appwrite\Migration\Migration;
use Utopia\App;
use Exception;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Query;
class V14 extends Migration
{
@ -208,6 +209,14 @@ class V14 extends Migration
} catch (\Throwable $th) {
Console::warning($th->getMessage());
}
/**
* Migrate Attributes
*/
$this->migrateAttributesAndCollections('attributes', $collection);
/**
* Migrate Indexes
*/
$this->migrateAttributesAndCollections('indexes', $collection);
}, $document);
}
}, $documents);
@ -220,6 +229,53 @@ class V14 extends Migration
} while (!is_null($nextCollection));
}
protected function migrateAttributesAndCollections(string $type, Document $collection): void
{
/**
* Offset pagination instead of cursor, since documents are re-created!
*/
$offset = 0;
$attributesCount = $this->projectDB->count($type, queries: [new Query('collectionId', Query::TYPE_EQUAL, [$collection->getId()])]);
do {
$documents = $this->projectDB->find($type, limit: $this->limit, offset: $offset, queries: [new Query('collectionId', Query::TYPE_EQUAL, [$collection->getId()])]);
$offset += $this->limit;
foreach ($documents as $document) {
go(function (Document $document, string $internalId, string $type) {
try {
/**
* Skip already migrated Documents.
*/
if (!is_null($document->getAttribute('databaseId'))) {
return;
}
/**
* Add Internal ID 'collectionInternalId' for Subqueries.
*/
$document->setAttribute('collectionInternalId', $internalId);
/**
* Add Internal ID 'databaseInternalId' for Subqueries.
*/
$document->setAttribute('databaseInternalId', '1');
/**
* Add Internal ID 'databaseId'.
*/
$document->setAttribute('databaseId', 'default');
/**
* Re-create Attribute.
*/
$this->projectDB->deleteDocument($document->getCollection(), $document->getId());
$this->projectDB->createDocument($document->getCollection(), $document->setAttribute('$id', "1_{$internalId}_{$document->getAttribute('key')}"));
} catch (\Throwable $th) {
Console::error("Failed to {$type} document: " . $th->getMessage());
}
}, $document, $collection->getInternalId(), $type);
}
} while ($offset < $attributesCount);
}
/**
* Migrate all Collections.
*
@ -580,40 +636,6 @@ class V14 extends Migration
$document->setAttribute('teamInternalId', $internalId);
}
break;
case 'attributes':
case 'indexes':
/**
* Add Internal ID 'collectionId' for Subqueries.
*/
if (!empty($document->getAttribute('collectionId')) && is_null($document->getAttribute('collectionInternalId'))) {
$internalId = $this->projectDB->getDocument('database_1', $document->getAttribute('collectionId'))->getInternalId();
$document->setAttribute('collectionInternalId', $internalId);
}
/**
* Add Internal ID 'databaseInternalId' for Subqueries.
*/
if (is_null($document->getAttribute('databaseInternalId'))) {
$document->setAttribute('databaseInternalId', '1');
}
/**
* Add Internal ID 'databaseInternalId' for Subqueries.
*/
if (is_null($document->getAttribute('databaseId'))) {
$document->setAttribute('databaseId', 'default');
}
try {
/**
* Re-create Collection Document
*/
$internalId = $this->projectDB->getDocument('database_1', $document->getAttribute('collectionId'))->getInternalId();
$this->projectDB->deleteDocument($document->getCollection(), $document->getId());
$this->projectDB->createDocument($document->getCollection(), $document->setAttribute('$id', "1_{$internalId}_{$document->getAttribute('key')}"));
} catch (\Throwable $th) {
Console::warning("Create Collection Document - {$th->getMessage()}");
}
$document = null;
break;
case 'platforms':
/**