Sha256: be5580a91e76c4dc95165b47b5e9ea3550549fedc5a84ad5ec34457f642c193c

Contents?: true

Size: 853 Bytes

Versions: 52

Compression:

Stored size: 853 Bytes

Contents

# Changes all the COLUMNS in the table with TABLE_NAME that are required from the table's mode, but were previously
# `:null => true`, to `:null => false`.
#
#  @abstract Subclass and define COLUMNS as Array<Symbol> and TABLE_NAME as Symbol.
class MetasploitDataModels::ChangeRequiredColumnsToNullFalse < ActiveRecord::Migration
  # Marks all the COLUMNS as `:null => true`
  def down
    # Use self.class:: so constants are resolved in subclasses instead of this class.
    self.class::COLUMNS.each do |column|
      change_column_null(self.class::TABLE_NAME, column, true)
    end
  end

  # Marks all the COLUMNS as `:null => false`
  def up
    # Use self.class:: so constants are resolved in subclasses instead of this class.
    self.class::COLUMNS.each do |column|
      change_column_null(self.class::TABLE_NAME, column, false)
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

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