-
-
Save vbguard/cf7da5934efb48b908fa752bcb91b754 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defined_indexes = Model.index_specifications.map { |s| s.fields.map(&:to_s) }; | |
existing_indexes = Model.collection.indexes.map { |i| i['key'].keys }; | |
missing_indexes = defined_indexes - existing_indexes | |
# => [] | |
extra_indexes = existing_indexes - defined_indexes - [['_id']] | |
# => [] | |
################################################################################# | |
# if the arrays are correct (hopefully the indexes have {background: true} flag), | |
# then you're good to run | |
Model.create_indexes # or Model.remove_indexes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment