feat: Add option keepUnknownIndexes to retain indexes which are not specified in schema (#9857)

This commit is contained in:
Rahul Lanjewar
2025-10-03 18:05:34 +05:30
committed by GitHub
parent b7faabb569
commit 89fad468c3
6 changed files with 64 additions and 2 deletions

View File

@@ -349,7 +349,10 @@ export class DefinedSchemas {
Object.keys(cloudSchema.indexes).forEach(indexName => {
if (!this.isProtectedIndex(localSchema.className, indexName)) {
if (!localSchema.indexes || !localSchema.indexes[indexName]) {
newLocalSchema.deleteIndex(indexName);
// If keepUnknownIndex is falsy, then delete all unknown indexes from the db.
if(!this.schemaOptions.keepUnknownIndexes){
newLocalSchema.deleteIndex(indexName);
}
} else if (
!this.paramsAreEquals(localSchema.indexes[indexName], cloudSchema.indexes[indexName])
) {