Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement skip-<feature> options in CLI commands #2634

Open
jmikola opened this issue May 6, 2024 · 3 comments
Open

Implement skip-<feature> options in CLI commands #2634

jmikola opened this issue May 6, 2024 · 3 comments

Comments

@jmikola
Copy link
Member

jmikola commented May 6, 2024

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)

@jmikola
Copy link
Member Author

jmikola commented May 6, 2024

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.

jmikola added a commit to jmikola/mongodb-odm that referenced this issue May 6, 2024
Currently, commands can either process all definitions (default behavior) or specify individual definitions. This allows the commands to rely on default behavior (e.g. $createOrder) but omit processing of search indexes, which may be more stringent requirements.

Note: this is similar to the disable-validators option that already existed in UpdateCommand; however, doctrine#2634 suggests renaming that if additional "skip" options are introduced.
jmikola added a commit to jmikola/mongodb-odm that referenced this issue May 13, 2024
Currently, commands can either process all definitions (default behavior) or specify individual definitions. This allows the commands to rely on default behavior (e.g. $createOrder) but omit processing of search indexes, which may be more stringent requirements.

Note: this is similar to the disable-validators option that already existed in UpdateCommand; however, doctrine#2634 suggests renaming that if additional "skip" options are introduced.
jmikola added a commit that referenced this issue May 22, 2024
* Model search index mappings

* Store default search index name in ClassMetadata

* Support search indexes in SchemaManager

* Support search indexes in CLI commands

Adds default implementations for "process" methods in AbstractCommand, which throw BadMethodCallException.

Renames internal methods in ShardCommand to no longer override "index" base methods, since sharding methods in SchemaManager do much more than process indexes.

* Update phpstan baseline for unmodeled search index structs

The fields struct is recursive, which is not supported by phpstan. The analyzers struct may be technically possible to model, but the complexity isn't worth the effort.

* Require driver 1.17+ for search index APIs

* Add skip-search-indexes option to schema CLI commands

Currently, commands can either process all definitions (default behavior) or specify individual definitions. This allows the commands to rely on default behavior (e.g. $createOrder) but omit processing of search indexes, which may be more stringent requirements.

Note: this is similar to the disable-validators option that already existed in UpdateCommand; however, #2634 suggests renaming that if additional "skip" options are introduced.

* Update baseline for Psalm 5.24.0

* SearchIndex annotation docs

* Search indexes chapter
@nikophil
Copy link

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!

@alcaeus
Copy link
Member

alcaeus commented Jul 31, 2024

@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!

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

No branches or pull requests

3 participants