Revision 3ace60a5
Added by Ohad Levy almost 12 years ago
- ID 3ace60a5690ded35e264cc8188d11ae4b8ba5dd7
db/migrate/20110803114134_add_subnet_and_domain_to_host_groups.rb | ||
---|---|---|
class AddSubnetAndDomainToHostGroups < ActiveRecord::Migration
|
||
def self.up
|
||
add_column :hostgroups, :subnet_id, :integer
|
||
add_column :hostgroups, :domain_id, :integer
|
||
add_column :hostgroups, :subnet_id, :integer unless column_exists? :hostgroups, :subnet_id
|
||
add_column :hostgroups, :domain_id, :integer unless column_exists? :hostgroups, :domain_id
|
||
end
|
||
|
||
def self.down
|
||
remove_column :hostgroups, :subnet_id
|
||
remove_column :hostgroups, :domain_id
|
||
remove_column :hostgroups, :subnet_id if column_exists? :hostgroups, :subnet_id
|
||
remove_column :hostgroups, :domain_id if column_exists? :hostgroups, :domain_id
|
||
end
|
||
end
|
db/migrate/20120623002052_add_ok_hosts_book_mark.rb | ||
---|---|---|
|
||
def self.up
|
||
Bookmark.find_or_create_by_name_and_query_and_controller :name => "ok hosts", :query => 'last_report > "35 minutes ago" and status.enabled = true and status.applied = 0 and status.failed = 0 and status.pending = 0', :controller=> "hosts", :public => true
|
||
rescue
|
||
# don't fail because we can't create a bookmark
|
||
true
|
||
end
|
||
|
||
def self.down
|
db/migrate/20120624081510_add_auditable_name_and_associated_name_to_audit.rb | ||
---|---|---|
class AddAuditableNameAndAssociatedNameToAudit < ActiveRecord::Migration
|
||
def self.up
|
||
add_column :audits, :auditable_name, :string unless column_exists? :audits, :auditable_name
|
||
add_column :audits, :auditable_name, :string unless column_exists? :audits, :auditable_name
|
||
add_column :audits, :associated_name, :string unless column_exists? :audits, :associated_name
|
||
add_index :audits, :id unless index_exists? :audits, :id
|
||
add_index :audits, :id unless index_exists? :audits, :id
|
||
Audit.reset_column_information
|
||
say "About to review all audits, this may take a while..."
|
||
Audit.includes(:user, :auditable, :associated).find_in_batches do |audits|
|
||
... | ... | |
end
|
||
|
||
def self.down
|
||
remove_index :audits, :id
|
||
remove_column :audits, :associated_name
|
||
remove_column :audits, :auditable_name
|
||
remove_index :audits, :id if index_exists? :audits, :id
|
||
remove_column :audits, :associated_name if column_exists? :audits, :associated_name
|
||
remove_column :audits, :auditable_name if column_exists? :audits, :auditable_name
|
||
end
|
||
end
|
db/migrate/20120624094034_add_os_family_to_ptable.rb | ||
---|---|---|
class AddOsFamilyToPtable < ActiveRecord::Migration
|
||
def self.up
|
||
add_column :ptables, :os_family, :string
|
||
remove_column :ptables, :operatingsystem_id
|
||
add_column :ptables, :os_family, :string unless column_exists? :ptables, :os_family
|
||
remove_column :ptables, :operatingsystem_id if column_exists? :ptables, :operatingsystem_id
|
||
Ptable.reset_column_information
|
||
Ptable.all.each do |p|
|
||
family = p.operatingsystems.map(&:family).uniq.first rescue nil
|
||
... | ... | |
end
|
||
|
||
def self.down
|
||
remove_column :ptables, :os_family
|
||
add_column :ptables, :operatingsystem_id, :integer
|
||
remove_column :ptables, :os_family if column_exists? :ptables, :os_family
|
||
add_column :ptables, :operatingsystem_id, :integer unless column_exists? :ptables, :operatingsystem_id
|
||
end
|
||
end
|
db/migrate/20120705130038_add_attributes_to_compute_resources.rb | ||
---|---|---|
class AddAttributesToComputeResources < ActiveRecord::Migration
|
||
def self.up
|
||
add_column :compute_resources, :attrs, :text
|
||
add_column :compute_resources, :attrs, :text unless column_exists? :compute_resources, :attrs
|
||
end
|
||
|
||
def self.down
|
||
remove_column :compute_resources, :attrs
|
||
remove_column :compute_resources, :attrs if column_exists? :compute_resources, :attrs
|
||
end
|
||
end
|
Also available in: Unified diff
minimal fix for unexplained db migrations failures, refs #1736