1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

Merge remote-tracking branch 'origin/main' into release-python-sdk

This commit is contained in:
Jake Barnby 2024-03-09 17:11:39 +01:00
commit 3850b3bbe4
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -84,27 +84,29 @@ class V20 extends Migration
Query::equal('array', [true]),
]) as $attribute
) {
$foundIndex = false;
$collectionId = "database_{$attribute['databaseInternalId']}_collection_{$attribute['collectionInternalId']}";
foreach (
$this->documentsIterator('indexes', [
Query::equal('databaseInternalId', [$attribute['databaseInternalId']]),
Query::equal('collectionInternalId', [$attribute['collectionInternalId']]),
]) as $index
) {
if (in_array($attribute->getAttribute('key'), $index->getAttribute('attributes'))) {
if (\in_array($attribute->getAttribute('key'), $index->getAttribute('attributes'))) {
try {
$this->projectDB->deleteIndex($collectionId, $index->getId());
$this->projectDB->deleteIndex($collectionId, $index->getAttribute('key'));
} catch (Throwable $th) {
Console::warning("Failed to delete index: {$th->getMessage()}");
} finally {
$foundIndex = true;
}
try {
$this->projectDB->deleteDocument('indexes', $index->getId());
} catch (Throwable $th) {
Console::warning("Failed to remove index: {$th->getMessage()}");
}
}
}
if ($foundIndex === true) {
$this->projectDB->updateAttribute($collectionId, $attribute['key'], $attribute['type']);
}
$this->projectDB->updateAttribute($collectionId, $attribute['key'], $attribute['type']);
}
}
@ -117,18 +119,15 @@ class V20 extends Migration
$this->projectDB->setNamespace("_$internalProjectId");
// Support database array type migration
$foundIndex = false;
foreach ($collection['attributes'] ?? [] as $attribute) {
if ($attribute['array'] === true) {
foreach ($collection['indexes'] ?? [] as $index) {
if (in_array($attribute['$id'], $index['attributes'])) {
if (\in_array($attribute['$id'], $index['attributes'])) {
$this->projectDB->deleteIndex($id, $index['$id']);
$foundIndex = true;
}
}
if ($foundIndex === true) {
$this->projectDB->updateAttribute($id, $attribute['$id'], $attribute['type']);
}
$this->projectDB->updateAttribute($id, $attribute['$id'], $attribute['type']);
}
}