summaryrefslogtreecommitdiff
path: root/lib/generators/nifty/scaffold/templates/migration.rb
blob: 02fd6bd4c0d8019b1e3d7b0b895d6965b177abb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Create<%= class_name.pluralize.delete('::') %> < ActiveRecord::Migration
  def self.up
    create_table :<%= table_name || plural_name.split('/').last %> do |t|
    <%- for attribute in model_attributes -%>
      t.<%= attribute.type %> :<%= attribute.name %>
    <%- end -%>
    <%- unless options[:skip_timestamps] -%>
      t.timestamps
    <%- end -%>
    end
  end

  def self.down
    drop_table :<%= table_name || plural_name.split('/').last %>
  end
end