Sha256: ebd3d8f13a82168b4ac3218b2b33f07920a38b5bc627e02c30c4c77d708d20e4

Contents?: true

Size: 505 Bytes

Versions: 88

Compression:

Stored size: 505 Bytes

Contents

class AddDisplayNameToReportsTable < ActiveRecord::Migration

	class Report < ActiveRecord::Base
	end

	def self.up

		add_column :reports, :name, :string, :limit => 63

		# Migrate to have a default name.
		
		Report.find(:all).each do |report|
			rtype = report.rtype.to_s =~ /^([A-Z0-9]+)\x2d/i ? $1 : "AUDIT"
			default_name = rtype[0,57].downcase.capitalize + "-" + report.id.to_s[0,5]
			report.name = default_name
			report.save
		end
	end

	def self.down
		remove_column :reports, :name
	end

end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
metasploit_data_models-0.22.4 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.22.4-java db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.22.3 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.22.3-java db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.22.2 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.22.2-java db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.22.1 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.22.1-java db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.21.3 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.21.3-java db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.21.2 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.21.2-java db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.21.1 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.21.0 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.21.0-java db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.21.0.pre.engine.pre.requires db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.20.1.pre.recog db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.20.1-java db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.20.1 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-0.20.0 db/migrate/20111011110000_add_display_name_to_reports_table.rb