diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 725c163c73..af7e3a3ad2 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -125,9 +125,6 @@ function createAttribute(string $databaseId, string $collectionId, Document $att throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded'); } - $dbForProject->deleteCachedDocument('database_' . $db->getInternalId(), $collectionId); - $dbForProject->deleteCachedCollection('database_' . $db->getInternalId() . '_collection_' . $collection->getInternalId()); - $database ->setType(DATABASE_TYPE_CREATE_ATTRIBUTE) ->setDatabase($db) @@ -1488,9 +1485,6 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/attributes/:key $attribute = $dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'deleting')); } - $dbForProject->deleteCachedDocument('database_' . $db->getInternalId(), $collectionId); - $dbForProject->deleteCachedCollection('database_' . $db->getInternalId() . '_collection_' . $collection->getInternalId()); - $database ->setType(DATABASE_TYPE_DELETE_ATTRIBUTE) ->setCollection($collection) @@ -1813,8 +1807,6 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/indexes/:key') $index = $dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'deleting')); } - $dbForProject->deleteCachedDocument('database_' . $db->getInternalId(), $collectionId); - $database ->setType(DATABASE_TYPE_DELETE_INDEX) ->setDatabase($db) diff --git a/app/init.php b/app/init.php index 5cdc577a37..d18752088b 100644 --- a/app/init.php +++ b/app/init.php @@ -279,6 +279,8 @@ Database::addFilter( return null; }, function (mixed $value, Document $document, Database $database) { + $database->deleteCachedDocument('database_' . $database->getInternalId(), $document['collectionId']); + $database->deleteCachedCollection('database_' . $database->getInternalId() . '_collection_' . $document['collectionInternalId']); return $database ->find('attributes', [ Query::equal('collectionInternalId', [$document->getInternalId()]), @@ -294,6 +296,7 @@ Database::addFilter( return null; }, function (mixed $value, Document $document, Database $database) { + $database->deleteCachedDocument('database_' . $document->getInternalId(), $document['collectionId']); return $database ->find('indexes', [ Query::equal('collectionInternalId', [$document->getInternalId()]),