app/models/fields/custom_field.rb
def db_transition_safety(old_type, new_type = as)
    old_col, new_col = [old_type, new_type].map { |t| column_type(t).to_s }
    return :null if old_col == new_col # no transition needed
    return :safe if SAFE_DB_TRANSITIONS[:one].any? do |start, final|
      old_col == start.to_s && new_col == final.to_s # one-to-one
    end
    return :safe if SAFE_DB_TRANSITIONS[:any].any? do |col_set|
      [old_col, new_col].all? { |c| col_set.include?(c.to_s) } # any-to-any
    end

    :unsafe # Else, unsafe.
  end
# When changing a custom field's type, it may be necessary to
# change the column type in the database. This method returns
# the safety of a given transition.
# Returns:
#   :null   => no transition needed
#   :safe   => transition is safe
#   :unsafe => transition is unsafe
#------------------------------------------------------------------------------
When changing a custom field's type, it may be necessary to
change the column type in the database. This method returns
the safety of a given transition.
Returns:
:null   => no transition needed
:safe   => transition is safe
:unsafe => transition is unsafe
When changing a custom field ' s type it may be necessary to change the column type in the database . This method returns the safety of a given transition . Returns : : null = > no transition needed : safe = > transition is safe : unsafe = > transition is unsafe
def db_transition_safety(old_type, new_type = as)
    old_col, new_col = [old_type, new_type].map { |t| column_type(t).to_s }
    return :null if old_col == new_col 
    return :safe if SAFE_DB_TRANSITIONS[:one].any? do |start, final|
      old_col == start.to_s && new_col == final.to_s 
    end
    return :safe if SAFE_DB_TRANSITIONS[:any].any? do |col_set|
      [old_col, new_col].all? { |c| col_set.include?(c.to_s) } 
    end
    :unsafe 
  end
def db_transition_safety ( old_type , new_type = as ) old_col , new_col = [ old_type , new_type ] . map { | t | column_type ( t ) . to_s } return :null if old_col == new_col return :safe if SAFE_DB_TRANSITIONS [ :one ] . any? do | start , final | old_col == start . to_s && new_col == final . to_s end return :safe if SAFE_DB_TRANSITIONS [ :any ] . any? do | col_set | [ old_col , new_col ] . all? { | c | col_set . include? ( c . to_s ) } end :unsafe end
When changing a custom field's type, it may be necessary to
change the column type in the database.
When changing a custom field ' s type it may be necessary to change the column type in the database .
# no transition needed # one-to-one # any-to-any # Else, unsafe.
old_type
new_type
as