Sha256: 952c9a505bf38629c4a15353dfd01d205e04f5f6c5301388fc84e2d6fdc4c59b

Contents?: true

Size: 603 Bytes

Versions: 2

Compression:

Stored size: 603 Bytes

Contents

class <%= migration_class_name %> < ActiveRecord::Migration
  def change
    create_table :<%= table_name %> do |t|
<% fields.add.each do |field| -%>
      t.<%= field.type %> :<%= field.name %><%= field.opts_text %>
<% end -%>
<% if options[:timestamps] %>
      t.timestamps null: false
<% end -%>
    end
<% indexes.add.each do |index| -%>
    add_index :<%= table_name %>, <%= index.fields_text %><%= index.opts_text %>
<% end -%>
<% fields.add.select(&:reference?).reject(&:polymorphic?).each do |field| -%>
    add_foreign_key :<%= table_name %>, :<%= field.name.pluralize %>
<% end -%>
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
schemaless-0.0.5 lib/generators/schemaless/migrations/templates/create_table.rb
schemaless-0.0.3 lib/generators/schemaless/migrations/templates/create_table.rb