Skip to content

Conversation

nirinchev
Copy link
Collaborator

This resolves MONGOSH-2139 by adding an extra field - allowMigrations for each collection in sh.status(). Additionally, adds two helpers - sh.enableMigrations(ns) and sh.disableMigrations(ns) that internally call the setAllowMigrations admin command.

@Copilot Copilot AI review requested due to automatic review settings September 23, 2025 10:27
@nirinchev nirinchev requested a review from a team as a code owner September 23, 2025 10:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds migration management functionality to the MongoDB shell API by implementing sh.enableMigrations() and sh.disableMigrations() helper methods, and enhancing sh.status() to display migration status for collections.

  • Adds two new helper methods that internally use the setAllowMigrations admin command
  • Enhances sh.status() to include an allowMigrations field for each collection
  • Includes comprehensive test coverage for both unit and integration scenarios

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/shell-api/src/shard.ts Implements the core migration helper methods and private _setAllowMigrations function
packages/shell-api/src/shard.spec.ts Adds comprehensive unit and integration tests for the new migration functionality
packages/shell-api/src/helpers.ts Enhances getPrintableShardStatus to include allowMigrations field in collection output
packages/i18n/src/locales/en_US.ts Adds documentation entries for the new migration helper methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

collRes.allowMigrations =
coll.permitMigrations !== false && coll.allowMigrations !== false;
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

The logic for determining allowMigrations uses both permitMigrations and allowMigrations fields with double negation. This could be simplified and made more explicit by using positive logic: (coll.permitMigrations !== false) && (coll.allowMigrations !== false) or better yet, explicit boolean conversion with default values to make the intent clearer.

Suggested change
coll.permitMigrations !== false && coll.allowMigrations !== false;
(coll.permitMigrations ?? true) && (coll.allowMigrations ?? true);

Copilot uses AI. Check for mistakes.

@nirinchev
Copy link
Collaborator Author

The test failures seem to be pre-existing, so going to go ahead and merge this.

@nirinchev nirinchev merged commit af60369 into main Sep 25, 2025
149 of 155 checks passed
@nirinchev nirinchev deleted the ni/sharded-migrations branch September 25, 2025 15:43
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.

2 participants