Sha256: 16c00befde7c50deaa565d33914a48da1209ce5388e77457898b1d7afa36b94a

Contents?: true

Size: 1.08 KB

Versions: 22

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[4.2]
  #
  # 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

22 entries across 22 versions & 2 rubygems

Version Path
wg-metasploit_data_models-4.1.4.02 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-6.0.5 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-6.0.4 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-6.0.3 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-6.0.2 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-6.0.1 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-6.0.0 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-5.0.6 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-5.0.5 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-5.0.4 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-5.0.3 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-5.0.2 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-5.0.1 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-5.0.0 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-4.1.4 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-4.1.3 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-4.1.2 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-4.1.1 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-4.1.0 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb
metasploit_data_models-4.0.2 db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb