Merge branch '1.6.x' into feat-1.6.x-new-sdk-class

This commit is contained in:
Jake Barnby
2025-01-21 00:50:16 +13:00
committed by GitHub
8 changed files with 69 additions and 37 deletions
+13
View File
@@ -40,6 +40,7 @@ use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Datetime as DatetimeValidator;
use Utopia\Database\Validator\Index as IndexValidator;
use Utopia\Database\Validator\IndexDependency as IndexDependencyValidator;
use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\Permissions;
use Utopia\Database\Validator\Queries;
@@ -2637,6 +2638,18 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/attributes/:key
throw new Exception(Exception::ATTRIBUTE_NOT_FOUND);
}
/**
* Check index dependency
*/
$validator = new IndexDependencyValidator(
$collection->getAttribute('indexes'),
$dbForProject->getAdapter()->getSupportForCastIndexArray(),
);
if (! $validator->isValid($attribute)) {
throw new Exception(Exception::INDEX_DEPENDENCY);
}
// Only update status if removing available attribute
if ($attribute->getAttribute('status') === 'available') {
$attribute = $dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'deleting'));