Commit b7bfdec3 by Dmitry Polushkin

Updated migration generator template.

parent 32199e21
class <%= migration_name %> < ActiveRecord::Migration
def self.up
def change
<% attachments.each do |attachment| -%>
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name, :string
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type, :string
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size, :integer
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at, :datetime
<% end -%>
end
def self.down
<% attachments.each do |attachment| -%>
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_fingerprint, :string, length: 32
<% end -%>
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment