summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2009-02-12 08:20:43 +1100
committerJames Turnbull <james@lovedthanlost.net>2009-02-12 08:20:43 +1100
commitf0ac3aef53a08e271a5c243f17785cdb58f1f5ef (patch)
treea06d22ed7f4dda63d3f5676ad354ad368d434722 /lib
parent319822af6d58c3e0c391e86cfd836ec31de43c67 (diff)
downloadpuppet-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.rb8
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