Tag your rails migrations
Outrigger allows you to tag your migrations so that you can have complete control. This is especially useful for zero downtime deploys to Production environments.
Starting with version
1.2.3, this gem requires RuboCop version 0.52.0 or higher, because of
a backwards-incompatible change to how cops report offenses.
gem "rubocop", "~> 0.52.0"
gem outriggerto your Gemfile and run
- Tag migrations like so.
class PreDeployMigration < ActiveRecord::Migration tag :predeploy end class PostDeployMigration < ActiveRecord::Migration tag :super_fun end
- Run only the migrations you want.
If your application is also using Switchman to manage multiple shards, you'll
rake db:migrate:tagged task to run against all shards, not
just the default shard. To do this, add to a rake task file such as
Passing multiple tags to
db:migrate:tagged means only run migrations that have
all of the given tags.
rake db:migrate:tagged[predeploy, dynamodb] means run only migrations
tagged with both
dynamodb. It will not run migrations tagged
Outrigger comes with a custom RuboCop linter that you can add to your project, to verify that all migrations have at least one valid tag.
Put this into your
require: - outrigger/cops/migration/tagged Migration/Tagged: Enabled: true AllowedTags: - predeploy - postdeploy
AllowedTags as necessary. Note that due to a bug in RuboCop, you'll
currently get a warning on each run:
Warning: unrecognized cop Migration/Tagged found in .rubocop.yml
This is unfortunate, but can be safely ignored.