Sha256: e089102eac241c8fd6e47ad8e8b1e1501e923572bc8db718979521f2dc4af89a
Contents?: true
Size: 1.31 KB
Versions: 8
Compression:
Stored size: 1.31 KB
Contents
class <%= migration_class_name %> < ActiveRecord::Migration def change <%- if !model.schema.table_exists? -%> create_table :<%= model.schema.prefixed_table_name %> unless table_exists?(:<%= model.schema.prefixed_table_name %>) <%- end -%> <%- model.schema.diff(:fields, :add).each do |field| -%> add_column :<%= model.schema.prefixed_table_name %>, <%= field.name.inspect %>, <%= field.type.inspect %><%= ", #{field.options.inspect}" if !field.options.blank? %> unless column_exists?(:<%= model.schema.prefixed_table_name %>, <%= field.name.inspect %>) <%- end -%> <%- model.schema.diff(:indexes, :add).each do |index| -%> add_index :<%= model.schema.prefixed_table_name %>, <%= index.name.inspect %><%= ", #{index.options.inspect}" if !index.options.blank? %> unless index_exists?(:<%= model.schema.prefixed_table_name %>, <%= index.name.inspect %>) <%- end -%> <%- model.schema.diff(:joins, :add).each do |join| -%> unless table_exists?(:<%= join.table %>) create_table :<%= join.table %>, :id => false do |t| t.integer <%= join.key1.inspect %> t.integer <%= join.key2.inspect %> end <%- if join.index -%> add_index :<%= join.table %>, <%= join.key1.inspect %> add_index :<%= join.table %>, <%= join.key2.inspect %> <%- end -%> end <%- end -%> end end
Version data entries
8 entries across 8 versions & 1 rubygems