diff options
author | James Turnbull <james@lovedthanlost.net> | 2009-02-12 08:20:43 +1100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-02-12 08:20:43 +1100 |
commit | f0ac3aef53a08e271a5c243f17785cdb58f1f5ef (patch) | |
tree | a06d22ed7f4dda63d3f5676ad354ad368d434722 /lib | |
parent | 319822af6d58c3e0c391e86cfd836ec31de43c67 (diff) | |
download | puppet-f0ac3aef53a08e271a5c243f17785cdb58f1f5ef.tar.gz puppet-f0ac3aef53a08e271a5c243f17785cdb58f1f5ef.tar.xz puppet-f0ac3aef53a08e271a5c243f17785cdb58f1f5ef.zip |
Fixed #1959 - Added column protection for environment schema migration
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/rails/database/003_add_environment_to_host.rb | 8 |
1 files changed, 6 insertions, 2 deletions
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 |