Sha256: a5e7e6cceb0e28521e30a9a4fa2f525dc871dff6b4e2b7c923b76c9a94c7d89b

Contents?: true

Size: 829 Bytes

Versions: 2

Compression:

Stored size: 829 Bytes

Contents

module WarnOnColumnRemoval
  def remove_column(table_name, column_name, type = nil, options = {})
    puts column_deprecation_status(table_name, column_name)

    super
  end

  def column_deprecation_status(table_name, column_name)
    begin
      klass = table_name.to_s.singularize.camelize.constantize
    rescue NameError
      return "WARNING: Couldn't find model for table #{table_name}. I can't tell " +
        "if column #{column_name} has been deprecated."
    end

    if klass.try(:deprecated_column_list).to_a.include?(column_name.to_s)
      "OK: #{table_name}.#{column_name} has been deprecated."
    else
      "WARNING: #{table_name}.#{column_name} has not been deprecated. Please " +
        "use the `deprecated_columns` macro to avoid crashing the application " +
        "at deploy time."
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deprecated_columns-0.1.1 lib/deprecated_columns/warn_on_column_removal.rb
deprecated_columns-0.1.0 lib/deprecated_columns/warn_on_column_removal.rb