Sha256: 9cbf5f9bbc5fe872b868fdaa996206b6eaff32ff2b117dc37d1a84e618fff27d

Contents?: true

Size: 1.08 KB

Versions: 143

Compression:

Stored size: 1.08 KB

Contents

# Changes web_vulns.confidence from text to integer as it is populated with integers.
class ChangeWebVulnsConfidenceToInteger < ActiveRecord::Migration
  #
  # CONSTANTS
  #

  # Columns in {TABLE} whose type needs to be change.
  COLUMN = :confidence
  # The correct type for {COLUMN}.
  NEW_TYPE = :integer
  # The incorrect type for {COLUMN}.
  OLD_TYPE = :text
  # The table in which {COLUMN} is defined.
  TABLE = :web_vulns

  #
  # Methods
  #

  # Changes web_vulns.confidence back to text
  #
  # @return [void]
  def down
    alter_type(:to => OLD_TYPE)
  end

  # Changes web_vulns.confidence to integer
  #
  # @return [void]
  def up
    alter_type(:to => NEW_TYPE)
  end

  private

  # Alters {COLUMN} type in {TABLE} from old to new type
  #
  # @param options [Hash{Symbol => #to_s}]
  # @option options [#to_s] :from The old type name.
  # @option options [#to_s] :to The new type name.
  def alter_type(options={})
    options.assert_valid_keys(:to)

    new = options.fetch(:to)

    execute "ALTER TABLE #{TABLE} ALTER COLUMN #{COLUMN} TYPE #{new} USING confidence::#{new}"
  end
end

Version data entries

143 entries across 143 versions & 1 rubygems

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