1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

updating generators

This commit is contained in:
Aaron Patterson 2010-11-17 14:57:46 -08:00
parent c1a63c8dba
commit 4d35f8b661
3 changed files with 6 additions and 6 deletions

View file

@ -1,5 +1,5 @@
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 @@ class <%= migration_class_name %> < ActiveRecord::Migration
<%- 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 %>

View file

@ -1,5 +1,5 @@
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 @@ class <%= migration_class_name %> < ActiveRecord::Migration
end
end
def self.down
def down
drop_table :<%= table_name %>
end
end

View file

@ -1,5 +1,5 @@
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 @@ class <%= migration_class_name %> < ActiveRecord::Migration
add_index :<%= session_table_name %>, :updated_at
end
def self.down
def down
drop_table :<%= session_table_name %>
end
end