Skip to content

Commit 3a46221

Browse files
fix: suggested changes
1 parent 502fa81 commit 3a46221

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

spec/DefinedSchemas.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ describe('DefinedSchemas', () => {
371371
expect(schema.indexes).toEqual(indexes);
372372
});
373373

374-
it('should delete unknown indexes when dropUnknownIndexes is not set', async () => {
374+
it('should delete unknown indexes when keepUnknownIndexes is not set', async () => {
375375
const server = await reconfigureServer();
376376

377377
let indexes = { complex: { createdAt: 1, updatedAt: 1 } };
@@ -394,16 +394,16 @@ describe('DefinedSchemas', () => {
394394
expect(schema.indexes).toBeUndefined();
395395
});
396396

397-
it('should delete unknown indexes when dropUnknownIndexes is set to true', async () => {
397+
it('should delete unknown indexes when keepUnknownIndexes is set to false', async () => {
398398
const server = await reconfigureServer();
399399

400400
let indexes = { complex: { createdAt: 1, updatedAt: 1 } };
401401

402-
let schemas = { definitions: [{ className: 'Test', indexes }], dropUnknownIndexes: true };
402+
let schemas = { definitions: [{ className: 'Test', indexes }], keepUnknownIndexes: false };
403403
await new DefinedSchemas(schemas, server.config).execute();
404404

405405
indexes = {};
406-
schemas = { definitions: [{ className: 'Test', indexes }], dropUnknownIndexes: true };
406+
schemas = { definitions: [{ className: 'Test', indexes }], keepUnknownIndexes: false };
407407
// Change indexes
408408
await new DefinedSchemas(schemas, server.config).execute();
409409
let schema = await new Parse.Schema('Test').get();
@@ -417,15 +417,15 @@ describe('DefinedSchemas', () => {
417417
expect(schema.indexes).toBeUndefined();
418418
});
419419

420-
it('should not delete unknown indexes when dropUnknownIndexes is set to false', async () => {
420+
it('should not delete unknown indexes when keepUnknownIndexes is set to true', async () => {
421421
const server = await reconfigureServer();
422422

423423
const indexes = { complex: { createdAt: 1, updatedAt: 1 } };
424424

425-
let schemas = { definitions: [{ className: 'Test', indexes }], dropUnknownIndexes: false };
425+
let schemas = { definitions: [{ className: 'Test', indexes }], keepUnknownIndexes: true };
426426
await new DefinedSchemas(schemas, server.config).execute();
427427

428-
schemas = { definitions: [{ className: 'Test', indexes: {} }], dropUnknownIndexes: false };
428+
schemas = { definitions: [{ className: 'Test', indexes: {} }], keepUnknownIndexes: true };
429429

430430
// Change indexes
431431
await new DefinedSchemas(schemas, server.config).execute();

src/Options/Definitions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ module.exports.SchemaOptions = {
2828
action: parsers.booleanParser,
2929
default: false,
3030
},
31-
dropUnknownIndexes: {
32-
env: 'PARSE_SERVER_SCHEMA_DROP_UNKNOWN_INDEXES',
31+
keepUnknownIndexes: {
32+
env: 'PARSE_SERVER_SCHEMA_KEEP_UNKNOWN_INDEXES',
3333
help:
34-
'Drops indexes that are not defined in the schema and are present in the database. Set this false if you are adding indexes manually so that it wont be dropped when you run schema migration',
34+
'Keep indexes that are not defined in the schema and are present in the database. Set this to true if you are adding indexes manually so that it wont be dropped when you run schema migration',
3535
action: parsers.booleanParser,
36-
default: true,
36+
default: false,
3737
},
3838
lockSchemas: {
3939
env: 'PARSE_SERVER_SCHEMA_LOCK_SCHEMAS',

src/Options/docs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Options/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export interface SchemaOptions {
2525
/* Is true if Parse Server will reject any attempts to modify the schema while the server is running.
2626
:DEFAULT: false */
2727
lockSchemas: ?boolean;
28-
/* Drops indexes that are not defined in the schema and are present in the database. Set this false if you are adding indexes manually so that it wont be dropped when you run schema migration
29-
:DEFAULT: true */
30-
dropUnknownIndexes: ?boolean;
28+
/* Keep indexes that are not defined in the schema and are present in the database. Set this to true if you are adding indexes manually so that it wont be dropped when you run schema migration
29+
:DEFAULT: false */
30+
keepUnknownIndexes: ?boolean;
3131
/* Execute a callback before running schema migrations. */
3232
beforeMigration: ?() => void | Promise<void>;
3333
/* Execute a callback after running schema migrations. */

src/SchemaMigrations/DefinedSchemas.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ export class DefinedSchemas {
349349
Object.keys(cloudSchema.indexes).forEach(indexName => {
350350
if (!this.isProtectedIndex(localSchema.className, indexName)) {
351351
if (!localSchema.indexes || !localSchema.indexes[indexName]) {
352-
// Only delete indexes which are present in database if dropUnknownIndexes is `true`
353-
if(this.schemaOptions.dropUnknownIndexes !== false){
352+
// If keepUnknownIndex is falsy, then delete all unknown indexes from the db.
353+
if(!this.schemaOptions.keepUnknownIndexes){
354354
newLocalSchema.deleteIndex(indexName);
355355
}
356356
} else if (

src/SchemaMigrations/Migrations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface SchemaOptions {
66
deleteExtraFields: ?boolean;
77
recreateModifiedFields: ?boolean;
88
lockSchemas: ?boolean;
9-
dropUnknownIndexes: ?boolean;
9+
keepUnknownIndexes: ?boolean;
1010
beforeMigration: ?() => void | Promise<void>;
1111
afterMigration: ?() => void | Promise<void>;
1212
}

0 commit comments

Comments
 (0)