Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Migration/Destinations/Appwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Comment thread
abnegate marked this conversation as resolved.
|| $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;
}

Expand Down
Loading