Skip to content

Instantly share code, notes, and snippets.

@mswieboda
Created August 9, 2017 16:52
Show Gist options
  • Save mswieboda/04aeba19e6561157eb36301be5eebfbb to your computer and use it in GitHub Desktop.
Save mswieboda/04aeba19e6561157eb36301be5eebfbb to your computer and use it in GitHub Desktop.
Adding Zero Downtime Migrations Gem AzDMG

Adding Zero Downtime Migrations Gem (AzDMG)

Using the gem zero_downtime_migrations

A simple example is adding a migration such as adding a column with a defalut value: zero_downtime_migrations README#Adding a Column with a Default with default: true for a :boolean column:

class AddDefaultToCampaignsTestingZDM < ActiveRecord::Migration
  def change
    add_column :direct_campaigns, :zero_migration_test, :boolean, default: true
  end
end

This throws an error when migrating via:

bundle exec rake db:migrate

If this potentially halts current work and is too frustrating to deal with immediately, there are several ways to ignore a specific migration. Using the safety_assured block, or method marks code to be ignored, or the shell environment can be used, like SAFETY_ASSURED=1 bundle exec rake db:migrate --trace. Several more ways detailed here too: Disabling "zero downtime migration" enforcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment