mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
refactor(migrations): adapt migration and deps to main
Fold the migration-resource-link schema provisioning and document backfill into main's V25 migration instead of a standalone V25: only the class mapped to the release version (2.0.0 => V25) is executed, so a separate migration would never run. Main's existing V25 collection work is preserved and the migrations-collection attributes/indexes plus the resource-link document backfill are layered on top. Gate the V27 request/response filters on < 2.0.0 (the release the fields ship in) instead of the branch's 1.9.6, keeping the API version aligned with the folded migration. Restore main's utopia-php/auth VCS repository alongside the utopia-php/migration one, keep utopia-php/messaging ^2.0, and regenerate the lock so only utopia-php/migration moves to the resource-selector branch. APP_VERSION_STABLE and the migration version map stay at main's values. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
68299a5a61
commit
221e9727da
6 files changed
+525
-371
No files matched your search
@@ -919,7 +919,7 @@ Http::init()
|
||||
if (version_compare($requestFormat, '1.9.5', '<')) {
|
||||
$request->addFilter(new RequestV26());
|
||||
}
|
||||
if (version_compare($requestFormat, '1.9.6', '<')) {
|
||||
if (version_compare($requestFormat, '2.0.0', '<')) {
|
||||
$request->addFilter(new RequestV27());
|
||||
}
|
||||
}
|
||||
@@ -946,7 +946,7 @@ Http::init()
|
||||
*/
|
||||
$responseFormat = $request->getHeaderLine('x-appwrite-response-format', System::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', ''));
|
||||
if ($responseFormat) {
|
||||
if (version_compare($responseFormat, '1.9.6', '<')) {
|
||||
if (version_compare($responseFormat, '2.0.0', '<')) {
|
||||
$response->addFilter(new ResponseV27());
|
||||
}
|
||||
if (version_compare($responseFormat, '1.9.5', '<')) {
|
||||
|
||||
+16
-10
@@ -38,13 +38,17 @@
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/utopia-php/auth"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/utopia-php/migration"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.3.0",
|
||||
"php": ">=8.5.0",
|
||||
"ext-curl": "*",
|
||||
"ext-imagick": "*",
|
||||
"ext-mbstring": "*",
|
||||
@@ -62,14 +66,14 @@
|
||||
"utopia-php/abuse": "1.4.*",
|
||||
"utopia-php/agents": "2.*",
|
||||
"utopia-php/analytics": "0.15.*",
|
||||
"utopia-php/audit": "2.6.*",
|
||||
"utopia-php/auth": "^0.7",
|
||||
"utopia-php/cache": "^3.0",
|
||||
"utopia-php/audit": "2.9.*",
|
||||
"utopia-php/auth": "^0.10",
|
||||
"utopia-php/cache": "^3.0.0",
|
||||
"utopia-php/cli": "^0.24",
|
||||
"utopia-php/compression": "0.1.*",
|
||||
"utopia-php/config": "1.*",
|
||||
"utopia-php/console": "0.1.*",
|
||||
"utopia-php/database": "6.0.*",
|
||||
"utopia-php/database": "^6.0.0",
|
||||
"utopia-php/detector": "0.2.*",
|
||||
"utopia-php/domains": "^2.2",
|
||||
"utopia-php/emails": "0.7.*",
|
||||
@@ -77,24 +81,24 @@
|
||||
"utopia-php/dsn": "0.2.1",
|
||||
"utopia-php/http": "^2.0@RC",
|
||||
"utopia-php/fetch": "^1.1",
|
||||
"utopia-php/validators": "0.2.*",
|
||||
"utopia-php/validators": "0.3.*",
|
||||
"utopia-php/image": "0.8.*",
|
||||
"utopia-php/locale": "0.8.*",
|
||||
"utopia-php/lock": "0.2.*",
|
||||
"utopia-php/logger": "0.8.*",
|
||||
"utopia-php/messaging": "^1.2",
|
||||
"utopia-php/messaging": "^2.0",
|
||||
"utopia-php/migration": "dev-feat/drop-compound-resource-id#7ed62ca2e2279bf30fa2018655e045c59bb5bc3d as 1.17.3",
|
||||
"utopia-php/platform": "^1.0@RC",
|
||||
"utopia-php/pools": "1.*",
|
||||
"utopia-php/span": "3.0.*",
|
||||
"utopia-php/preloader": "0.2.*",
|
||||
"utopia-php/queue": "^0.21",
|
||||
"utopia-php/queue": "^0.22",
|
||||
"utopia-php/servers": "0.4.*",
|
||||
"utopia-php/registry": "0.5.*",
|
||||
"utopia-php/storage": "2.*",
|
||||
"utopia-php/system": "0.10.*",
|
||||
"utopia-php/telemetry": "^0.4",
|
||||
"utopia-php/vcs": "4.*",
|
||||
"utopia-php/vcs": "^4.4.2",
|
||||
"utopia-php/websocket": "1.0.*",
|
||||
"matomo/device-detector": "6.4.*",
|
||||
"dragonmantank/cron-expression": "3.4.*",
|
||||
@@ -104,7 +108,9 @@
|
||||
"spomky-labs/otphp": "11.*",
|
||||
"webonyx/graphql-php": "15.32.*",
|
||||
"league/csv": "9.14.*",
|
||||
"enshrined/svg-sanitize": "0.22.*"
|
||||
"enshrined/svg-sanitize": "0.22.*",
|
||||
"utopia-php/client": "^0.2.2",
|
||||
"open-runtimes/sdk-for-php": "^0.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-fileinfo": "*",
|
||||
|
||||
Generated
+392
-322
File diff suppressed because it is too large.
Load diff
@@ -3,10 +3,12 @@
|
||||
namespace Appwrite\Migration\Version;
|
||||
|
||||
use Appwrite\Migration\Migration;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Utopia\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Migration\Resource;
|
||||
|
||||
class V25 extends Migration
|
||||
@@ -24,51 +26,127 @@ class V25 extends Migration
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
* Migrate Collections.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception|Throwable
|
||||
*/
|
||||
private function migrateCollections(): void
|
||||
{
|
||||
if ($this->project->getSequence() === 'console') {
|
||||
return;
|
||||
$projectInternalId = $this->project->getSequence();
|
||||
|
||||
if (empty($projectInternalId)) {
|
||||
throw new Exception('Project ID is null');
|
||||
}
|
||||
|
||||
$id = 'migrations';
|
||||
$collectionType = match ($projectInternalId) {
|
||||
'console' => 'console',
|
||||
default => 'projects',
|
||||
};
|
||||
|
||||
$this->dbForProject->purgeCachedCollection($id);
|
||||
$this->dbForProject->purgeCachedDocument(Database::METADATA, $id);
|
||||
$collections = $this->collections[$collectionType];
|
||||
|
||||
$attributes = [
|
||||
'resourceInternalId',
|
||||
'parentResourceId',
|
||||
'parentResourceInternalId',
|
||||
'parentResourceType',
|
||||
'destinationResourceId',
|
||||
'destinationResourceType',
|
||||
];
|
||||
try {
|
||||
$this->createAttributesFromCollection($this->dbForProject, $id, $attributes);
|
||||
} catch (Throwable $th) {
|
||||
Console::warning('Failed to create attributes "' . \implode(', ', $attributes) . "\" in collection {$id}: {$th->getMessage()}");
|
||||
}
|
||||
foreach ($collections as $collection) {
|
||||
$id = $collection['$id'];
|
||||
|
||||
$indexes = [
|
||||
'_key_resourceType',
|
||||
'_key_resourceInternalId',
|
||||
'_key_parentResourceId',
|
||||
'_key_parentResourceType',
|
||||
'_key_parentResourceInternalId',
|
||||
'_key_destinationResourceId',
|
||||
'_key_destinationResourceType',
|
||||
];
|
||||
foreach ($indexes as $index) {
|
||||
try {
|
||||
$this->createIndexFromCollection($this->dbForProject, $id, $index);
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("Failed to create index \"{$index}\" from {$id}: {$th->getMessage()}");
|
||||
if (empty($id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Console::log("Migrating collection \"{$id}\"");
|
||||
|
||||
$this->dbForProject->purgeCachedCollection($id);
|
||||
$this->dbForProject->purgeCachedDocument(Database::METADATA, $id);
|
||||
|
||||
switch ($id) {
|
||||
case 'projects':
|
||||
if ($collectionType === 'console') {
|
||||
try {
|
||||
$this->createIndexFromCollection($this->dbForProject, $id, '_key_accessedAt');
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("Failed to create index \"_key_accessedAt\" from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
}
|
||||
$this->dbForProject->purgeCachedCollection($id);
|
||||
break;
|
||||
|
||||
case 'installations':
|
||||
if ($collectionType === 'console') {
|
||||
foreach (['personalAccessToken', 'personalRefreshToken'] as $attribute) {
|
||||
try {
|
||||
$this->dbForProject->updateAttribute($id, $attribute, size: 2048);
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("Failed to resize attribute \"{$attribute}\" in collection {$id}: {$th->getMessage()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->dbForProject->purgeCachedCollection($id);
|
||||
break;
|
||||
|
||||
case 'databases':
|
||||
if ($collectionType === 'projects') {
|
||||
try {
|
||||
$this->createAttributeFromCollection($this->dbForProject, $id, 'status');
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("Failed to create attribute \"status\" in collection {$id}: {$th->getMessage()}");
|
||||
}
|
||||
$this->dbForProject->purgeCachedCollection($id);
|
||||
|
||||
// Backfill existing databases so the stored value matches the intended default.
|
||||
// Materialize the matched documents before updating any of them: updating
|
||||
// "status" removes rows from the isNull() set, and the offset-based iterator
|
||||
// would otherwise skip un-processed rows as the filtered set shrinks mid-scan.
|
||||
$databases = \iterator_to_array($this->documentsIterator($id, [Query::isNull('status')]));
|
||||
foreach ($databases as $database) {
|
||||
try {
|
||||
$this->dbForProject->updateDocument($id, $database->getId(), new Document([
|
||||
'status' => 'ready',
|
||||
]));
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("Failed to backfill \"status\" for database {$database->getId()}: {$th->getMessage()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'migrations':
|
||||
if ($collectionType === 'projects') {
|
||||
$attributes = [
|
||||
'resourceInternalId',
|
||||
'parentResourceId',
|
||||
'parentResourceInternalId',
|
||||
'parentResourceType',
|
||||
'destinationResourceId',
|
||||
'destinationResourceType',
|
||||
];
|
||||
try {
|
||||
$this->createAttributesFromCollection($this->dbForProject, $id, $attributes);
|
||||
} catch (Throwable $th) {
|
||||
Console::warning('Failed to create attributes "' . \implode(', ', $attributes) . "\" in collection {$id}: {$th->getMessage()}");
|
||||
}
|
||||
|
||||
$indexes = [
|
||||
'_key_resourceType',
|
||||
'_key_resourceInternalId',
|
||||
'_key_parentResourceId',
|
||||
'_key_parentResourceType',
|
||||
'_key_parentResourceInternalId',
|
||||
'_key_destinationResourceId',
|
||||
'_key_destinationResourceType',
|
||||
];
|
||||
foreach ($indexes as $index) {
|
||||
try {
|
||||
$this->createIndexFromCollection($this->dbForProject, $id, $index);
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("Failed to create index \"{$index}\" from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
$this->dbForProject->purgeCachedCollection($id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->dbForProject->purgeCachedCollection($id);
|
||||
}
|
||||
|
||||
protected function migrateDocument(Document $document): Document
|
||||
|
||||
@@ -6,7 +6,7 @@ use Appwrite\Utopia\Request\Filter;
|
||||
|
||||
class V27 extends Filter
|
||||
{
|
||||
// Convert 1.9.5 params to 1.9.6
|
||||
// Convert 1.9.5 params to 2.0.0
|
||||
public function parse(array $content, string $model): array
|
||||
{
|
||||
return match ($model) {
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Appwrite\Utopia\Response\Filters;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Filter;
|
||||
|
||||
// Convert 1.9.6 data format to 1.9.5 format
|
||||
// Convert 2.0.0 Data format to 1.9.5 format
|
||||
class V27 extends Filter
|
||||
{
|
||||
public function parse(array $content, string $model): array
|
||||
|
||||
Reference in new issue
Block a user