Skip to content

Commit

Permalink
Merge pull request #14 from jamesjefferies/only-add-columns-if-not-al…
Browse files Browse the repository at this point in the history
…ready-there

Add columns if they don't already exist
  • Loading branch information
andymayer authored Dec 12, 2017
2 parents 860d6d6 + 8d2f2c2 commit f2f00cc
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
class AddPinfirmableColumnsToResource < ActiveRecord::Migration[5.0]
def change
model = (ENV["MODEL"] || "user").downcase.pluralize.to_sym
add_column model, :pinfirmable_pin, :string
add_column model, :pinfirmable_tries, :integer, default: 0
add_column model, :pinfirmable_lockout, :datetime, default: nil
unless column_exists?(model, :pinfirmable_pin)
add_column model, :pinfirmable_pin, :string
add_column model, :pinfirmable_tries, :integer, default: 0
add_column model, :pinfirmable_lockout, :datetime, default: nil
end
end
end

0 comments on commit f2f00cc

Please sign in to comment.