X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=vendor%2Frails%2Frailties%2Flib%2Frails_generator%2Fgenerators%2Fcomponents%2Fmigration%2Ftemplates%2Fmigration.rb;fp=vendor%2Frails%2Frailties%2Flib%2Frails_generator%2Fgenerators%2Fcomponents%2Fmigration%2Ftemplates%2Fmigration.rb;h=ca35a432294924c2c6f9064aa8305f3404f92f9c;hb=d115f2e23823271635bad69229a42cd8ac68debe;hp=0000000000000000000000000000000000000000;hpb=37cb670bf3ddde90b214e591f100ed4446469484;p=depot.git diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb b/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb new file mode 100644 index 0000000..ca35a43 --- /dev/null +++ b/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb @@ -0,0 +1,11 @@ +class <%= class_name.underscore.camelize %> < ActiveRecord::Migration + def self.up<% attributes.each do |attribute| %> + <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%> + <%- end %> + end + + def self.down<% attributes.reverse.each do |attribute| %> + <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end -%> + <%- end %> + end +end