From f0ac3aef53a08e271a5c243f17785cdb58f1f5ef Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 12 Feb 2009 08:20:43 +1100 Subject: Fixed #1959 - Added column protection for environment schema migration --- lib/puppet/rails/database/003_add_environment_to_host.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/rails/database/003_add_environment_to_host.rb b/lib/puppet/rails/database/003_add_environment_to_host.rb index 4593a06f7..3ed10e946 100644 --- a/lib/puppet/rails/database/003_add_environment_to_host.rb +++ b/lib/puppet/rails/database/003_add_environment_to_host.rb @@ -1,9 +1,13 @@ class AddEnvironmentToHost < ActiveRecord::Migration def self.up - add_column :hosts, :environment, :string + unless ActiveRecord::Base.connection.columns(:hosts).collect {|c| c.name}.include?("environment") + add_column :hosts, :environment, :string + end end def self.down - remove_column :hosts, :environment + if ActiveRecord::Base.connection.columns(:hosts).collect {|c| c.name}.include?("environment") + remove_column :hosts, :environment + end end end -- cgit