Open FunkyloverOne opened 6 years ago
That's how i managed to create a task to run db:mongoid:create_indexes on each deploy
Add this to your config/deploy.rb.
namespace :deploy do
desc "Create mongoid indexes."
task :create_indexes do
on roles(:app) do
within "#{release_path}" do
with rails_env: "#{fetch(:stage)}" do
info '[deploy:create_indexes] Run `rake db:mongoid:create_indexes'
execute :rake, 'db:mongoid:create_indexes'
end
end
end
end
after 'deploy:updated', 'deploy:create_indexes'
end
Hey guys, I would like to be able to automatically create Mongoid indexes on each deploy, like we do with migrations with relational databases.
(I think that it's totally OK to do so, just not to forget to create some new indexes for some new models for example, if I'm wrong please correct me.)
I have wrote some code, based on your code for migrations, it doesn't work locally yet, and I don't really know why, but it's close to something that should work :) Maybe it could be added to this gem, take a look at what I got so far: