doctrine/mongodb-odm

Implement `skip-<feature>` options in CLI commands

jmikola opened this issue · 3 comments

Feature Request

Allow users to explicitly exclude features (e.g. search indexes) in CLI commands.

Q A
New Feature yes
RFC no
BC Break no

Summary

The CLI commands for managing schema entities (e.g. creating collections and indexes) attempt to process all schema definitions by default. This is problematic for features such as Atlas Search indexes, which have more restrictions.

For example, CreateCommand defines an ordered list (i.e. $createOrder) for schema entities to process when no command line arguments are specified. If any Atlas Search indexes exist in class metadata, those will be processed by default; however, that may not be supported in a development environment.

If users want to exclude certain DDL operations, they cannot rely on the default order and must manually enumerate all schema entities to process. Consider introducing skip-<feature> options to allow users to opt out of specific features.

Context: #2630 (comment)

Note: #2630 introduces a skip-search-indexes option to UpdateCommand, which already had a disable-validators option with the same meaning. If we move forward with this issue, we should rename disable-validators to skip-validators and deprecate the existing name.

Hello,

I discovered this issue because I've just upgraded to v2.8.0 of this lib, and had an error Unrecognized pipeline stage name: '$listSearchIndexes' when running UpdateCommand. I think I have this error because we're using an old mongo version: listSearchIndexes has landed in mongo 6.0.7 but still, there are some older versions still maintained which do not support this instruction.

Maybe it would be a nice addition to check if the mongo version is compatible, before using it by default?

thanks!

@nikophil thanks for bringing up the issue. I've created #2671 to work around the issue gracefully where possible. I'd appreciate it if you could test it and report back in the PR so I can tag a fixed version soon. Thanks!