mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix(migrations): drop response-model legacy fallback
The Migration response model split legacy composite resourceId at read time so brand-new SDKs would see a clean shape on docs that hadn't been backfilled by V25 yet. That window is short (V25 runs on every 1.9.4 boot), so the worker fallback alone is enough. Old SDK clients still get the composite shape via the V25 response filter; the worker still tolerates legacy docs via resolveResourceIds(). This change only removes the in-window normalization for new SDKs reading not-yet-backfilled docs — they'll see resourceId="db:col" with empty parentResourceId for the few seconds V25 is running, then it's correct. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
87892e7895
commit
acaf2f7900
@@ -152,8 +152,6 @@ class Migration extends Model
|
||||
|
||||
public function filter(Document $document): Document
|
||||
{
|
||||
$this->normalizeLegacyResourceId($document);
|
||||
|
||||
$errors = $document->getAttribute('errors', []);
|
||||
if (empty($errors)) {
|
||||
return $document;
|
||||
@@ -174,34 +172,4 @@ class Migration extends Model
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits a legacy "{databaseId}:{tableId}" resourceId into resourceId /
|
||||
* parentResourceId for documents that haven't been backfilled by V25 yet
|
||||
* (or that were just restored from a pre-1.9.4 backup). The new attributes
|
||||
* stay populated where they already are; this only fills gaps.
|
||||
*/
|
||||
private function normalizeLegacyResourceId(Document $document): void
|
||||
{
|
||||
$resourceId = (string) $document->getAttribute('resourceId', '');
|
||||
$parentResourceId = (string) $document->getAttribute('parentResourceId', '');
|
||||
|
||||
if ($parentResourceId !== '' || !\str_contains($resourceId, ':')) {
|
||||
return;
|
||||
}
|
||||
|
||||
[$databaseId, $tableId] = \explode(':', $resourceId, 2);
|
||||
|
||||
$document->setAttribute('resourceId', $tableId);
|
||||
$document->setAttribute('parentResourceId', $databaseId);
|
||||
|
||||
// Pre-1.9.4 docs stored the database family ("database" / "documentsdb"
|
||||
// / "vectorsdb") in resourceType. Promote it to parentResourceType and
|
||||
// surface the leaf type so the response shape is consistent.
|
||||
$legacyType = (string) $document->getAttribute('resourceType', '');
|
||||
if ((string) $document->getAttribute('parentResourceType', '') === '' && $legacyType !== '') {
|
||||
$document->setAttribute('parentResourceType', $legacyType);
|
||||
$document->setAttribute('resourceType', 'collection');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user