Skip to content

Instantly share code, notes, and snippets.

@umar-siddiqui
Last active February 4, 2016 07:38
Show Gist options
  • Save umar-siddiqui/5583f914780e55a55ea2 to your computer and use it in GitHub Desktop.
Save umar-siddiqui/5583f914780e55a55ea2 to your computer and use it in GitHub Desktop.
Remove other clients from DB
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