Skip to content

Conversation

RahulLanjewar93
Copy link
Contributor

@RahulLanjewar93 RahulLanjewar93 commented Sep 9, 2025

Pull Request

Issue

Deletes additional indexes which are not specified in schema.

Closes: #9112

Approach

We are always deleting the indexes in the db if they are not present in the provided schema definition.
However that may not be the case since the user may add addtional indexes as parse does not support all kinds of indexes. To retain such indexes, provided an option keepUnknownIndexes

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK

Summary by CodeRabbit

  • New Features

    • Added a new schema option to control whether indexes present in the database but not defined in the schema are kept (option defaults to false — unknown indexes are dropped by default).
  • Documentation

    • Updated schema options docs with description and guidance for preserving manually added indexes.
  • Tests

    • Renamed and added tests covering both keep and drop behaviors.

Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title feat: dropUnknownIndexes feat: DropUnknownIndexes Sep 9, 2025
Copy link

parse-github-assistant bot commented Sep 9, 2025

🚀 Thanks for opening this pull request!

Copy link

coderabbitai bot commented Sep 9, 2025

📝 Walkthrough

Walkthrough

Adds a new SchemaOptions flag keepUnknownIndexes (default false) with docs and types, and conditions deletion of database indexes not defined in the local schema on this flag. Test(s) for unknown-index deletion/preservation were renamed/added accordingly.

Changes

Cohort / File(s) Summary of Edits
Tests: index handling
spec/DefinedSchemas.spec.js
Renamed an existing test and added two tests that assert unknown DB indexes are deleted when keepUnknownIndexes is false and preserved when keepUnknownIndexes is true.
Options: definitions
src/Options/Definitions.js
Added new boolean option keepUnknownIndexes to SchemaOptions (env: PARSE_SERVER_SCHEMA_KEEP_UNKNOWN_INDEXES, boolean parser, default: false) positioned after deleteExtraFields.
Options: docs & types
src/Options/docs.js, src/Options/index.js
Documented keepUnknownIndexes in options docs and added its type declaration (keepUnknownIndexes: ?boolean) to the exported SchemaOptions interface.
Schema migration logic
src/SchemaMigrations/DefinedSchemas.js
Guarded deletion of indexes present in the DB but not in the local schema behind this.schemaOptions.keepUnknownIndexes (delete only when falsy); added clarifying comment.
Migrations types
src/SchemaMigrations/Migrations.js
Added keepUnknownIndexes: ?boolean to the SchemaOptions type declaration used by migrations.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Admin as Admin/Config
  participant Server as Parse Server (SchemaMigration)
  participant DB as Database

  Admin->>Server: Start migration with SchemaOptions (keepUnknownIndexes = true/false)
  Server->>DB: Fetch current DB indexes (cloud schema)
  Server->>Server: Compare local schema indexes vs DB indexes

  alt keepUnknownIndexes = false
    Server->>DB: Drop indexes not defined in local schema
    Note right of Server #DDEBF7: Unknown indexes removed
  else keepUnknownIndexes = true
    Server->>DB: Skip dropping unknown indexes
    Note right of Server #F7F3DE: Preserve existing DB indexes
  end

  Server->>DB: Create/add missing indexes defined in local schema
  Server-->>Admin: Migration complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

Pre-merge checks (5 passed)

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and concisely describes the primary change—introducing the keepUnknownIndexes option to prevent dropping indexes not defined in the schema—and matches the code implementation without extraneous details.
Linked Issues Check ✅ Passed The pull request introduces the keepUnknownIndexes option, updates the DefinedSchemas migration logic to respect this flag, adds tests for both flag states, and documents the new behavior, satisfying the core objective of allowing user-defined indexes to be preserved during schema migrations as described in issue #9112.
Out of Scope Changes Check ✅ Passed All modifications are directly related to adding and supporting the keepUnknownIndexes option—none of the changes touch unrelated code paths or introduce extraneous functionality beyond the scope defined in issue #9112.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed The pull request description faithfully follows the repository’s template by including the “Pull Request” boilerplate, a clear “Issue” section with the correct issue link in the Closes line, an “Approach” that describes the change, and a “Tasks” checklist reflecting added tests and documentation updates. All required headings and information are present and appropriately filled out.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Sep 9, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

@RahulLanjewar93 RahulLanjewar93 changed the title feat: DropUnknownIndexes feat: dropUnknownIndexes Sep 9, 2025
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title feat: dropUnknownIndexes feat: DropUnknownIndexes Sep 9, 2025
@RahulLanjewar93 RahulLanjewar93 changed the title feat: DropUnknownIndexes feat: dropUnknownIndexes Sep 9, 2025
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title feat: dropUnknownIndexes feat: DropUnknownIndexes Sep 9, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/SchemaMigrations/DefinedSchemas.js (1)

348-372: Use schemaOptions, not server config; avoid creating conflicting indexes when not dropping

Index deletion is gated by this.config.schema.dropUnknownIndexes, but all other migration flags read from this.schemaOptions. This makes per-run options ineffective and can break tests. Also, when dropUnknownIndexes is false, pushing a replacement into indexesToAdd without dropping first will likely fail (index name already exists).

   if (cloudSchema.indexes) {
+    const dropUnknown = this.schemaOptions.dropUnknownIndexes !== false; // default true
     Object.keys(cloudSchema.indexes).forEach(indexName => {
       if (!this.isProtectedIndex(localSchema.className, indexName)) {
         if (!localSchema.indexes || !localSchema.indexes[indexName]) {
-            // Only delete indexes which are present in database if dropUnknownIndexes is `true`
-            if(this.config.schema.dropUnknownIndexes){
-              newLocalSchema.deleteIndex(indexName);
-            }
+          // Delete only when allowed; otherwise warn in strict mode
+          if (dropUnknown) {
+            newLocalSchema.deleteIndex(indexName);
+          } else if (this.schemaOptions.strict === true) {
+            logger.warn(
+              `Index "${indexName}" exists in DB for "${localSchema.className}" but is not defined; keeping it because dropUnknownIndexes=false.`
+            );
+          }
         } else if (
           !this.paramsAreEquals(localSchema.indexes[indexName], cloudSchema.indexes[indexName])
         ) {
-            // Only delete indexes which are present in database if dropUnknownIndexes is `true`
-            if(this.config.schema.dropUnknownIndexes){
-              newLocalSchema.deleteIndex(indexName);
-            }
-            if (localSchema.indexes) {
-              indexesToAdd.push({
-                indexName,
-                index: localSchema.indexes[indexName],
-              });
-            }
+          // Replace only when allowed; otherwise warn and leave as-is
+          if (dropUnknown) {
+            newLocalSchema.deleteIndex(indexName);
+            if (localSchema.indexes) {
+              indexesToAdd.push({
+                indexName,
+                index: localSchema.indexes[indexName],
+              });
+            }
+          } else if (this.schemaOptions.strict === true) {
+            logger.warn(
+              `Index "${indexName}" differs for "${localSchema.className}" but dropUnknownIndexes=false; leaving existing index unchanged.`
+            );
+          }
         }
       }
     });
   }
spec/DefinedSchemas.spec.js (1)

374-395: Test name and setup inverted; make it explicitly exercise “true” path

Title says “false” but the behavior verified is the “true” path. Also make the flag explicit in the options object for clarity.

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

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

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

       indexes = {};
-      schemas = { definitions: [{ className: 'Test', indexes }] };
+      schemas = { definitions: [{ className: 'Test', indexes }], dropUnknownIndexes: true };
🧹 Nitpick comments (2)
src/Options/index.js (1)

28-30: Polish wording; fix grammar and clarity of the new option description

Tighten phrasing and fix “wont” → “won’t”. Also prefer “during schema migrations.”

-  /* 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
+  /* Drops indexes that are not defined in the schema but exist in the database. Set this to false if you add indexes manually so they won't be dropped during schema migrations.
   :DEFAULT: true */
   dropUnknownIndexes: ?boolean;
src/Options/docs.js (1)

7-7: Fix grammar in docs for dropUnknownIndexes

Use “Set this to false … won’t … during schema migrations.”

- * @property {Boolean} dropUnknownIndexes 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
+ * @property {Boolean} dropUnknownIndexes Drops indexes that are not defined in the schema but exist in the database. Set this to false if you add indexes manually so they won't be dropped during schema migrations.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82fdb0d and 84cf02c.

📒 Files selected for processing (5)
  • spec/DefinedSchemas.spec.js (2 hunks)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
  • src/SchemaMigrations/DefinedSchemas.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/Options/Definitions.js (1)
resources/buildConfigDefinitions.js (1)
  • parsers (12-12)
spec/DefinedSchemas.spec.js (2)
spec/helper.js (2)
  • reconfigureServer (171-205)
  • Parse (4-4)
src/SchemaMigrations/DefinedSchemas.js (1)
  • Parse (3-3)
🪛 Biome (2.1.2)
src/Options/index.js

[error] 30-30: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: Node 20
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: Node 18
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: Redis Cache
  • GitHub Check: Docker Build
🔇 Additional comments (2)
src/Options/index.js (1)

28-30: Configure Biome to parse Flow or exclude Flow-typed files
There’s no Biome config in the repo, so it’s using defaults that don’t recognize Flow’s “?boolean” syntax and error on the “?” token. Add a Biome config (for example a .biome.json or biome.config.js) with "language": "flow", or explicitly ignore the Flow-typed file pattern (e.g. "ignore": ["src/Options/*.js"]) so the Flow annotation isn’t parsed by Biome.

src/Options/Definitions.js (1)

31-37: Fix help text typo and clarify phrasing in source Options/index.js
Update the dropUnknownIndexes help string in Options/index.js (not Definitions.js) and re-run the generator so the updated text propagates. Change “wont” to “won’t” and rephrase to:
"Drops indexes that are not defined in the schema but exist in the database. Set this to false if you add indexes manually so they won't be dropped during schema migrations."

@RahulLanjewar93 RahulLanjewar93 changed the title feat: DropUnknownIndexes feat: add option 1dropUnknownIndexes1 to conditionally delete indexes if not specified in schema Sep 9, 2025
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title feat: add option 1dropUnknownIndexes1 to conditionally delete indexes if not specified in schema feat: Add option 1dropUnknownIndexes1 to conditionally delete indexes if not specified in schema Sep 9, 2025
@RahulLanjewar93 RahulLanjewar93 changed the title feat: Add option 1dropUnknownIndexes1 to conditionally delete indexes if not specified in schema feat: add option dropUnknownIndexes to conditionally delete indexes if not specified in schema Sep 9, 2025
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title feat: add option dropUnknownIndexes to conditionally delete indexes if not specified in schema feat: Add option dropUnknownIndexes to conditionally delete indexes if not specified in schema Sep 9, 2025
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.02%. Comparing base (82fdb0d) to head (502fa81).

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #9857      +/-   ##
==========================================
+ Coverage   92.99%   93.02%   +0.02%     
==========================================
  Files         187      187              
  Lines       15096    15097       +1     
  Branches      174      174              
==========================================
+ Hits        14039    14044       +5     
+ Misses       1045     1041       -4     
  Partials       12       12              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Options/index.js (1)

28-30: Polish the docstring; fix grammar and match existing option style.

Short, consistent phrasing; fix “wont” → “won’t”; clarify “Set to false…”.

-  /* 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
-  :DEFAULT: true */
+  /* Is true if Parse Server should drop database indexes that are present but not defined in the schema. Set to `false` to retain manually created indexes during schema migrations.
+  :DEFAULT: true */
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 99d820d and ae6a875.

📒 Files selected for processing (4)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
  • src/SchemaMigrations/DefinedSchemas.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/Options/docs.js
  • src/SchemaMigrations/DefinedSchemas.js
  • src/Options/Definitions.js
🧰 Additional context used
🪛 Biome (2.1.2)
src/Options/index.js

[error] 30-30: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: Node 20
  • GitHub Check: Redis Cache
  • GitHub Check: Node 18
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: Docker Build
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: Code Analysis (javascript)
🔇 Additional comments (1)
src/Options/index.js (1)

30-30: Biome parse hint is likely a false positive on Flow’s ?boolean.

If CI gates on Biome, consider excluding Flow type files or enabling a Flow-compatible parser for this path. No code change needed.

coderabbitai[bot]
coderabbitai bot previously approved these changes Sep 10, 2025
@RahulLanjewar93
Copy link
Contributor Author

@mtrezza what do you think? should we approach this problem some other way?

@mtrezza
Copy link
Member

mtrezza commented Sep 10, 2025

@Moumouls is the expert when it comes to defined schema, what do you think?

Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: the new option should be inverted, otherwise LGTM, good idea, and thanks for the PR @RahulLanjewar93 🚀

and the approach is correct !

@RahulLanjewar93
Copy link
Contributor Author

issue: the new option should be inverted, otherwise LGTM, good idea, and thanks for the PR @RahulLanjewar93 🚀

and the approach is correct !

Thanks, will make the changes.
There is one another approach, we get all the _SCHEMA documents from the db, then check _metadata.indexes with the current local schema. If there is any diff then delete them. By this approach we will ensure that we remove any indexes which were removed from the user parse schema. Other indexes such as unique/ttl etc should be defined separately and handled separately by the dev.

There is one another bug, if we add some indexes, run migration it works fine, but if we remove those indexes and run migration it does not update the corresponding _SCHEMA document in the db. To summarize, the old indexes will still be visible in _metadata.indexes.

So we have two approaches now

  1. Implement a flag, but devs will have to deletion of all indexes by themselves (including ones mentioned in parse schema).
  2. Devs should implement unique/ttl/etc index handling themselves. But regular indexes can be handled by parse server. (To get this working we will have to fix the issue i mentioned above)

@mtrezza @Moumouls Your thoughts?

@Moumouls
Copy link
Member

Moumouls commented Sep 10, 2025

I think the current approach is safe and simple. The real core issue is Defined Schema do not support creation of unique/ttl indexes (or other kind of indexes)

A great goal could be to implement a way to provide advanced indexes through Defined Schema, but i'm not 100% sure of the correct approach at this time

So the mode currently is:

  • Non authoritative behavior with the new option (possible stable indexes, and external sources indexes), parse server just "ensure" that defined schema managed indexes exist
  • Authoritative behavior (current behavior without options), parse server expect indexes to match managed indexes

@RahulLanjewar93 RahulLanjewar93 changed the title feat: Add option dropUnknownIndexes to conditionally delete indexes if not specified in schema feat: Add option keepUnknownIndexes to retain indexes which are not specified in schema Sep 10, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/Options/index.js (1)

28-30: Fix minor grammar in option description.

“wont” → “won’t”; tighten phrasing.

-  /* 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
+  /* Keep database indexes that are not defined in the schema. Set this to true if you add indexes manually so that they won't be dropped during schema migration.
   :DEFAULT: false */
   keepUnknownIndexes: ?boolean;
src/Options/Definitions.js (1)

31-37: Polish help text (grammar/clarity).

Same typo and phrasing as in the interface doc.

   keepUnknownIndexes: {
     env: 'PARSE_SERVER_SCHEMA_KEEP_UNKNOWN_INDEXES',
-    help:
-      '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',
+    help:
+      "Keep database indexes that are not defined in the schema. Set this to true if you add indexes manually so that they won't be dropped during schema migration.",
     action: parsers.booleanParser,
     default: false,
   },
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 502fa81 and 3a46221.

📒 Files selected for processing (6)
  • spec/DefinedSchemas.spec.js (2 hunks)
  • src/Options/Definitions.js (1 hunks)
  • src/Options/docs.js (1 hunks)
  • src/Options/index.js (1 hunks)
  • src/SchemaMigrations/DefinedSchemas.js (1 hunks)
  • src/SchemaMigrations/Migrations.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/SchemaMigrations/DefinedSchemas.js
  • src/Options/docs.js
🧰 Additional context used
🧬 Code graph analysis (2)
src/Options/Definitions.js (1)
resources/buildConfigDefinitions.js (1)
  • parsers (12-12)
spec/DefinedSchemas.spec.js (2)
spec/helper.js (2)
  • reconfigureServer (171-205)
  • Parse (4-4)
src/SchemaMigrations/DefinedSchemas.js (1)
  • Parse (3-3)
🪛 Biome (2.1.2)
src/Options/index.js

[error] 30-30: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

src/SchemaMigrations/Migrations.js

[error] 9-9: Expected a statement but instead found '?'.

Expected a statement here.

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Node 18
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: Node 20
  • GitHub Check: Redis Cache
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: Docker Build
🔇 Additional comments (4)
src/SchemaMigrations/Migrations.js (1)

9-9: Approve keepUnknownIndexes addition
No stale dropUnknownIndexes references found; keepUnknownIndexes is defined and used consistently in Options (index.js, docs.js, Definitions.js), Migrations.js, DefinedSchemas.js, and associated tests.

spec/DefinedSchemas.spec.js (3)

374-396: Default behavior test reads well.

Covers the “unset” (default false) path; assertions are precise after cleaning _id_.


397-418: Explicit false path test is correct.

Good coverage mirroring the default; expectations are strict and deterministic.


420-441: True path preservation test is solid.

Accurately validates preservation when keepUnknownIndexes is true.

@RahulLanjewar93
Copy link
Contributor Author

I think the current approach is safe and simple. The real core issue is Defined Schema do not support creation of unique/ttl indexes (or other kind of indexes)

A great goal could be to implement a way to provide advanced indexes through Defined Schema, but i'm not 100% sure of the correct approach at this time

So the mode currently is:

  • Non authoritative behavior with the new option (possible stable indexes, and external sources indexes), parse server just "ensure" that defined schema managed indexes exist
  • Authoritative behavior (current behavior without options), parse server expect indexes to match managed indexes

Have added the required changes

Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks @RahulLanjewar93

@RahulLanjewar93
Copy link
Contributor Author

LGTM thanks @RahulLanjewar93

Anyime mate

@Moumouls
Copy link
Member

I think we are all good here @mtrezza !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schema Migration Overriding exist Indexes
4 participants