提交 4d35f8b6 编写于 作者: A Aaron Patterson

updating generators

上级 c1a63c8d
class <%= migration_class_name %> < ActiveRecord::Migration
def self.up
def up
<% attributes.each do |attribute| -%>
<%- if migration_action -%>
<%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end %>
......@@ -7,7 +7,7 @@ def self.up
<%- end -%>
end
def self.down
def down
<% attributes.reverse.each do |attribute| -%>
<%- if migration_action -%>
<%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end %>
......
class <%= migration_class_name %> < ActiveRecord::Migration
def self.up
def up
create_table :<%= table_name %> do |t|
<% for attribute in attributes -%>
t.<%= attribute.type %> :<%= attribute.name %>
......@@ -10,7 +10,7 @@ def self.up
end
end
def self.down
def down
drop_table :<%= table_name %>
end
end
class <%= migration_class_name %> < ActiveRecord::Migration
def self.up
def up
create_table :<%= session_table_name %> do |t|
t.string :session_id, :null => false
t.text :data
......@@ -10,7 +10,7 @@ def self.up
add_index :<%= session_table_name %>, :updated_at
end
def self.down
def down
drop_table :<%= session_table_name %>
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册