capistrano / capistrano/rails

Mongoid indexes creation

Open
#222 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
901
Forks
262
PR merge metrics
No merged PRs in 30d

Description

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:

```ruby
namespace :mongoid do
desc 'Runs rake db:mongoid:create_indexes'
task create_indexes: [:set_rails_env] do
on fetch(:mongoid_servers) do
info '[mongoid:create_indexes] Run `rake db:mongoid:create_indexes`'
within release_path do
with rails_env: fetch(:rails_env) do
execute :rake, 'db:mongoid:create_indexes'
end
end
end
end

after 'deploy:updated', 'mongoid:create_indexes'
end

namespace :load do
task :defaults do
set :mongoid_role, fetch(:mongoid_role, :db)
set :mongoid_servers, -> { primary(fetch(:mongoid_role)) }
end
end
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the proposed Capistrano tasks for mongoid:create_indexes and the deploy:updated hook in the issue. Check how the repository defines Rails deployment tasks and how Mongoid exposes index creation. Done means a documented, working way to create indexes automatically during deployment, with appropriate tests or verification for the task behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
devops, release
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.