method
add_user_provided_columns
v4.2.7 -
Show latest stable
- Class:
ActiveRecord::Attributes::ClassMethods
add_user_provided_columns(schema_columns)private
No documentation available.
# File activerecord/lib/active_record/attributes.rb, line 112
def add_user_provided_columns(schema_columns)
existing_columns = schema_columns.map do |column|
new_type = user_provided_columns[column.name]
if new_type
column.with_type(new_type)
else
column
end
end
existing_column_names = existing_columns.map(&:name)
new_columns = user_provided_columns.except(*existing_column_names).map do |(name, type)|
connection.new_column(name, nil, type)
end
existing_columns + new_columns
end