aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/rails
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikachu.com>2011-01-01 01:19:56 +0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-01-04 11:16:52 -0800
commitad343d7263d0922bbe32f550e7057d55f2c4d311 (patch)
treeda25cb79802b85e949b731f293a97eed8d5c5b57 /activerecord/lib/rails
parent9e64dfad0df4ed8a10d2ad2a17cd0848017d652c (diff)
downloadrails-ad343d7263d0922bbe32f550e7057d55f2c4d311.tar.gz
rails-ad343d7263d0922bbe32f550e7057d55f2c4d311.tar.bz2
rails-ad343d7263d0922bbe32f550e7057d55f2c4d311.zip
Use Rails 3.1 `change` method in 'add_' migration generator
Diffstat (limited to 'activerecord/lib/rails')
-rw-r--r--activerecord/lib/rails/generators/active_record/migration/templates/migration.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb b/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
index 126b6f434b..ce8d7eed42 100644
--- a/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
+++ b/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
@@ -1,4 +1,11 @@
class <%= migration_class_name %> < ActiveRecord::Migration
+<%- if migration_action == 'add' -%>
+ def change
+<% attributes.each do |attribute| -%>
+ add_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %>
+<%- end -%>
+ end
+<%- else -%>
def up
<% attributes.each do |attribute| -%>
<%- if migration_action -%>
@@ -14,4 +21,5 @@ class <%= migration_class_name %> < ActiveRecord::Migration
<%- end -%>
<%- end -%>
end
+<%- end -%>
end