Skip to content

Commit

Permalink
added check to column existense in migrations for rails 3
Browse files Browse the repository at this point in the history
  • Loading branch information
nodecarter committed Dec 18, 2012
1 parent 0fe9a30 commit 9605172
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,27 @@ class AddStealthAllowedToUsers < ActiveRecord::Migration

# Rails 3
def up
self.class.add_stealth_allowed
unless column_exists? :users, :stealth_allowed
add_column :users, :stealth_allowed, :boolean, :default => false
end
end

def down
self.class.remove_stealth_allowed
if column_exists? :users, :stealth_allowed
remove_column :users, :stealth_allowed
end
end

class << self

# Rails 2
def up
add_stealth_allowed
add_column :users, :stealth_allowed, :boolean, :default => false
end

def down
remove_stealth_allowed
end

def add_stealth_allowed
add_column :users, :stealth_allowed, :boolean, :default => false
end

def remove_stealth_allowed
remove_column :users, :stealth_allowed
end

end
end

0 comments on commit 9605172

Please sign in to comment.