From ec680b918cbd178d690e35ca718923c7b8e167b0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 22 Jul 2026 16:01:44 +1200 Subject: [PATCH] fix: drive vectorsdb dimension from the embeddings column only The placeholder-only guard left a stale archived dimension uncorrected when it disagreed with the actual vector column size, while the previous always-sync overwrote it from any vector column. The embeddings column is the schema-defining vector of a vectorsdb collection, so it alone now drives dimension: mismatches are corrected from it and other vector columns never touch the value. Co-Authored-By: Claude Fable 5 --- src/Migration/Destinations/Appwrite.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index d816c1ad..33d149a7 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -87,6 +87,8 @@ class Appwrite extends Destination private const META_ATTRIBUTES = 'attributes'; private const META_INDEXES = 'indexes'; + private const VECTORSDB_EMBEDDINGS_KEY = 'embeddings'; + /** A database is provisioning while its resources transfer, ready once the run completes, or failed if creation errored. */ private const DATABASE_STATUS_PROVISIONING = 'provisioning'; private const DATABASE_STATUS_READY = 'ready'; @@ -1323,19 +1325,24 @@ private function entityTypeMetadata(Table $resource): array } /** + * The `embeddings` column is the schema-defining vector of a vectorsdb collection, so it alone + * drives the collection's `dimension` — correcting both the pre-dimension-archive placeholder + * and any stale archived value, while other vector columns never touch it. + * * @throws \Throwable */ private function syncVectorDimension(Column|Attribute $resource, string $type, UtopiaDocument $database, UtopiaDocument $table): void { if ( $type !== UtopiaDatabase::VAR_VECTOR + || $resource->getKey() !== self::VECTORSDB_EMBEDDINGS_KEY || $resource->getTable()->getDatabase()->getType() !== Resource::TYPE_DATABASE_VECTORSDB || !isset($this->collectionStructures[Resource::TYPE_DATABASE_VECTORSDB]) ) { return; } - if ((int) $table->getAttribute('dimension', 0) !== 0) { + if ((int) $table->getAttribute('dimension', 0) === $resource->getSize()) { return; }