Add migration for version 25 to ensure presenceLogs collection exists; update migration mapping for version 1.9.3. Remove redundant error assertion in PresenceTest.

This commit is contained in:
ArnabChatterjee20k
2026-04-29 14:32:57 +05:30
parent 59ee0901c9
commit 58c248f4f2
3 changed files with 35 additions and 1 deletions
+1
View File
@@ -95,6 +95,7 @@ abstract class Migration
'1.9.0' => 'V24',
'1.9.1' => 'V24',
'1.9.2' => 'V24',
'1.9.3' => 'V25',
];
/**
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace Appwrite\Migration\Version;
use Appwrite\Migration\Migration;
use Throwable;
use Utopia\Console;
use Utopia\Database\Database;
class V25 extends Migration
{
public function execute(): void
{
// Presence logs are only relevant for regular (project) databases.
if ($this->project->getSequence() === 'console') {
return;
}
$collectionId = 'presenceLogs';
try {
Console::info("Ensuring collection \"{$collectionId}\" exists for project \"{$this->project->getId()}\".");
$this->dbForProject->purgeCachedCollection($collectionId);
$this->dbForProject->purgeCachedDocument(Database::METADATA, $collectionId);
$this->createCollection($collectionId);
} catch (Throwable $th) {
Console::warning("Failed to create collection \"{$collectionId}\": {$th->getMessage()}");
// Re-throw so the migration fails fast and doesn't leave the system in a partially migrated state.
throw $th;
}
}
}
@@ -47,7 +47,6 @@ class PresenceTest extends Scope
], $payload);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertArrayNotHasKey('errors', $response['body']);
$this->assertEquals('online', $response['body']['data']['presencesUpsert']['status']);
$this->assertEquals('graphql', $response['body']['data']['presencesUpsert']['source']);
}