0.0
No commit activity in last 3 years
No release in over 3 years
A simple library for running zero-downtime with Rails and ActiveRecord.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
>= 0
~> 12.0
~> 3.5
~> 0.47

Runtime

< 5.2, >= 4.0.0
< 5.2, >= 4.0.0
 Project Readme

ZeroDowntime

Build Status

This is a minimal library to help run zero-downtime with rails and activerecord

Deprecated Columns

The most common use case is deprecating a column.

If you just drop a column, it will break any existing process that has cached the columns.

Example

We have a model Person

It has a single column :name

However we want to split this up into

  • :first_name
  • :last_name

We add a migration

class AddFirstAndLastNamesToPeople < ActiveRecord::Migration
  class SafePersone # safe model
    self.table_name :people
  end

  def up
    add_column :people, :first_name
    add_column :people, :last_name

    SafePerson.find_each do |person|
      *first_names, last_name = person.name.split(" ")

      person.first_name = first_names.join(" ")
      person.last_name = last_name
      person.save!
    end
  end
end

That's fine, but what to do with the deprecated :name column?

The answer, mark it as deprecated

class Person < ActiveRecord::Base
  deprecate_column :name
end

This will

  • Let us easily find it later
  • Stop anyone from using the column by accident
  • Ensure that once its deployed we can safely remove the column