diff options
author | Prem Sichanugrist <s@sikachu.com> | 2011-01-01 01:19:56 +0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-04 11:16:52 -0800 |
commit | ad343d7263d0922bbe32f550e7057d55f2c4d311 (patch) | |
tree | da25cb79802b85e949b731f293a97eed8d5c5b57 /activerecord/lib/rails | |
parent | 9e64dfad0df4ed8a10d2ad2a17cd0848017d652c (diff) | |
download | rails-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.rb | 8 |
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 |