Last active
February 4, 2016 07:38
-
-
Save umar-siddiqui/5583f914780e55a55ea2 to your computer and use it in GitHub Desktop.
Remove other clients from DB
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
client = Client.find_by(name: '<Client Name which we want to keep>') | |
models = Dir["/home/webonise/Projects/treeni-data-management/app/models/**/*.rb"] | |
.map{ |file_name| Object.const_get(file_name.split('/').last.split('.').first.camelize) } | |
.reject{|i| i == Client } | |
models.each do |model| | |
model.ne(client_id: client._id).destroy_all | |
end | |
Client.ne(_id: client._id).destroy_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment