lib/hobo_fields/field_spec.rb in hobofields-1.0.3 vs lib/hobo_fields/field_spec.rb in hobofields-1.1.0.pre0

- old
+ new

@@ -58,10 +58,14 @@ end def default options[:default] end + + def comment + options[:comment] + end def same_type?(col_spec) t = sql_type TYPE_SYNONYMS.each do |synonyms| if t.in? synonyms @@ -72,9 +76,19 @@ end def different_to?(col_spec) !same_type?(col_spec) || + # we should be able to use col_spec.comment, but col_spec has + # a nil table_name for some strange reason. + begin + if model.table_exists? + col_comment = ActiveRecord::Base.try.column_comment(col_spec.name, model.table_name) + col_comment != nil && col_comment != comment + else + false + end + end || begin check_attributes = [:null, :default] check_attributes += [:precision, :scale] if sql_type == :decimal && !col_spec.is_a?(SQLITE_COLUMN_CLASS) # remove when rails fixes https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2872 check_attributes -= [:default] if sql_type == :text && col_spec.is_a?(MYSQL_COLUMN_CLASS) check_attributes << :limit if sql_type.in?([:string, :text, :binary, :integer])