Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #10861 -remove unused columns from the hosts table #2472

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/models/host/managed.rb
Expand Up @@ -147,8 +147,6 @@ class Jail < ::Safemode::Jail
:if => Proc.new { |host| host.managed && host.pxe_build? && build? }
validates :ptable_id, :presence => {:message => N_("can't be blank unless a custom partition has been defined")},
:if => Proc.new { |host| host.managed and host.disk.empty? and not Foreman.in_rake? and host.pxe_build? and host.build? }
validates :serial, :format => {:with => /[01],\d{3,}n\d/, :message => N_("should follow this format: 0,9600n8")},
:allow_blank => true, :allow_nil => true
validates :provision_method, :inclusion => {:in => PROVISION_METHODS, :message => N_('is unknown')}, :if => Proc.new {|host| host.managed?}
validates :medium_id, :presence => true, :if => Proc.new { |host| host.validate_media? }
validate :provision_method_in_capabilities
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/v1/hosts/show.json.rabl
Expand Up @@ -6,7 +6,7 @@ attributes :name, :id, :ip, :environment_id, :last_report, :updated_at, :created
:comment, :disk, :installed_at, :model_id, :hostgroup_id, :owner_id, :owner_type,
:enabled, :puppet_ca_proxy_id, :managed, :use_image, :image_file, :uuid, :compute_resource_id,
:puppet_proxy_id, :certname, :image_id, :created_at, :updated_at,
:last_compile, :last_freshcheck, :serial, :source_file_id, :puppet_status, :root_pass
:last_compile, :puppet_status, :root_pass

if SETTINGS[:organizations_enabled]
attribute :organization_id
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/v2/hosts/main.json.rabl
Expand Up @@ -9,7 +9,7 @@ attributes :ip, :environment_id, :environment_name, :last_report, :mac, :realm_i
:enabled, :puppet_ca_proxy_id, :managed, :use_image, :image_file, :uuid, :compute_resource_id, :compute_resource_name,
:compute_profile_id, :compute_profile_name, :capabilities, :provision_method,
:puppet_proxy_id, :certname, :image_id, :image_name, :created_at, :updated_at,
:last_compile, :last_freshcheck, :serial, :source_file_id, :puppet_status
:last_compile, :puppet_status

if SETTINGS[:organizations_enabled]
attributes :organization_id, :organization_name
Expand Down
13 changes: 13 additions & 0 deletions db/migrate/20150618093433_remove_unused_fields_from_hosts.rb
@@ -0,0 +1,13 @@
class RemoveUnusedFieldsFromHosts < ActiveRecord::Migration
def up
remove_index :hosts, :source_file_id
remove_columns :hosts, :last_freshcheck, :serial, :source_file_id
end

def down
add_column :hosts, :last_freshcheck, :datetime
add_column :hosts, :serial, :string, :limit => 255
add_column :hosts, :source_file_id, :integer
add_index :hosts, :source_file_id
end
end