Method: DataType::Base#structure_changes_from

Defined in:
lib/dsl/data_type.rb

#structure_changes_from(current_structure = nil) ⇒ Object

Decides if and how a column will be changed Provide the details of a previously column, or simply nil to create a new column



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/dsl/data_type.rb', line 55

def structure_changes_from(current_structure = nil)
  new_structure = column
 
  if current_structure
    # General RDBMS data loss scenarios
    if new_structure[:limit] && current_structure[:limit].to_i != new_structure[:limit].to_i ||
       new_structure[:type] != current_structure[:type] ||
       !new_structure[:default].nil? && column_default_changed?(current_structure[:default], new_structure[:default])

       column
    else
      nil # No changes
    end
  else
    column
  end
end