annotate lib/generators/redmine_plugin_model/templates/migration.rb @ 1556:81dd71991dc1 feature_1136

hg-hash option does not appear reliable ("Not updating refs/notes/hg (new tip XXX does not contain YYY")
author Chris Cannam
date Wed, 13 Jan 2016 13:33:03 +0000
parents 433d4f72a19b
children
rev   line source
Chris@1115 1 class <%= @migration_class_name %> < ActiveRecord::Migration
Chris@1115 2 def change
Chris@1115 3 create_table :<%= @table_name %> do |t|
Chris@1115 4 <% attributes.each do |attribute| -%>
Chris@1115 5 t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
Chris@1115 6 <% end -%>
Chris@1115 7 <% if options[:timestamps] %>
Chris@1115 8 t.timestamps
Chris@1115 9 <% end -%>
Chris@1115 10 end
Chris@1115 11 <% attributes_with_index.each do |attribute| -%>
Chris@1115 12 add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
Chris@1115 13 <% end -%>
Chris@1115 14 end
Chris@1115 15 end