Sha256: aae34cae2336da0a54544c500848dca9ac1c048a49f820ee9fc01b535809a16b

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

class <%= migration_class_name %> < ActiveRecord::Migration
  def change
    create_table :<%= table_name %> do |t|
<% attributes.each do |attribute| -%>
      t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
<% end -%>
<% if parent_options[:author] -%>
      t.integer :author_id, <%= key_value :default, "0" %>, <%= key_value :null, "false" %>
<% end -%>
<% if parent_options[:project] -%>
      t.integer :project_id, <%= key_value :default, "0" %>, <%= key_value :null, "false" %>
<% end -%>
<% if options[:timestamps] %>
      t.timestamps
<% end -%>
    end
<% attributes_with_index.each do |attribute| -%>
    add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
<% end -%>
<% if parent_options[:author] -%>
    add_index :<%= table_name %>, :author_id
<% end -%>
<% if parent_options[:project] -%>
    add_index :<%= table_name %>, :project_id
<% end -%>
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redmine-generators-0.0.1 lib/redmine/generators/templates/active_record/model/migration.rb