Sha256: e46fc46ffb80bcc6b3941d329a8c05dc072bd6d27692a3017ef2582c753d8bd0
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
# -*- encoding : utf-8 -*- class Add<%= @model.attributes.collect{|a| a.name.camelize}.join('') %>ToUsers < ActiveRecord::Migration def self.up <%- @model.attributes.each do |attr| -%> <%- if attr.type.to_sym != :file -%> <%- if attr.belongs_to? or attr.nested_one? -%> add_column :users, :<%= attr.name %>, :integer <%- elsif !attr.references? -%> add_column :users, :<%= attr.name %>, :<%= attr.migration_field %> <%- end -%> <%- else -%> add_column :users, :<%= attr.name %>_file_name, :string add_column :users, :<%= attr.name %>_content_type, :string add_column :users, :<%= attr.name %>_file_size, :integer add_column :users, :<%= attr.name %>_updated_at, :datetime <%- end -%> <%- end -%> end def self.down <%- @model.attributes.each do |attr| -%> <%- if attr.type.to_sym != :file -%> <%- if attr.belongs_to? or attr.nested_one? -%> remove_column :users, :<%= attr.name %> <%- elsif !attr.references? -%> remove_column :users, :<%= attr.name %> <%- end -%> <%- else -%> remove_column :users, :<%= attr.name %>_file_name remove_column :users, :<%= attr.name %>_content_type remove_column :users, :<%= attr.name %>_file_size remove_column :users, :<%= attr.name %>_updated_at <%- end -%> <%- end -%> end end
Version data entries
3 entries across 3 versions & 1 rubygems