Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (64 sloc) 2.3 KB


Build Status

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"


  1. Add gem outrigger to your Gemfile and run bundle install
  2. Tag migrations like so.
  class PreDeployMigration < ActiveRecord::Migration
    tag :predeploy
  class PostDeployMigration < ActiveRecord::Migration
    tag :super_fun
  1. Run only the migrations you want. rake db:migrate:tagged[predeploy] or rake db:migrate:tagged[super_fun]

Using with Switchman

If your application is also using Switchman to manage multiple shards, you'll want the 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 lib/tasks/myapp.rake:


Multiple Tags

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 predeploy and dynamodb. It will not run migrations tagged just predeploy.

RuboCop Linter

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 .rubocop.yml.

  - outrigger/cops/migration/tagged

  Enabled: true
    - predeploy
    - postdeploy

Modify 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.