Last active
October 4, 2019 21:47
-
-
Save exAspArk/36771c7b1a6d416eb9a25007f4ab1772 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