Sha256: 39cc1b16d70939a8b6724d1195d8f9b23aa621970cc5d59946241a92db916fea

Contents?: true

Size: 498 Bytes

Versions: 66

Compression:

Stored size: 498 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.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

66 entries across 66 versions & 1 rubygems

Version Path
metasploit_data_models-3.0.10 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-3.0.9 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-3.0.8 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-3.0.7 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-3.0.6 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-3.0.5 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.17 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-3.0.4 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-3.0.2 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-3.0.1 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-3.0.0 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.16 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.15 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.14 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.13 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.12 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.11 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.10 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.9 db/migrate/20111011110000_add_display_name_to_reports_table.rb
metasploit_data_models-2.0.8 db/migrate/20111011110000_add_display_name_to_reports_table.rb