Sha256: 8b3a29cc1d52f25d774593f0de288bb02659f004dd9286371d026a21b3310964

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

class <%= migration_name %> < ActiveRecord::Migration
  def self.up
<% if distributed -%>
    create_table :<%= table_name %>, :id => false do |t|
      t.string :id
<% else -%>
    create_table :<%= table_name %> do |t|
<% end -%>
<% for attribute in args_for_generation -%>
      t.<%= attribute.split(':')[1] %> :<%= attribute.split(':')[0] %>
<% end -%>
<% for model in belongs_tos -%>
<% if distributed -%>
      t.string :<%= model %>_id
<% else -%>
      t.references :<%= model %>
<% end -%>
<% end -%>
<% if attachment_field.size > 0 -%>
<% if RxSettings.attachment_plugin == 'paperclip' -%>
      # For paperclip
      t.column :<%= attachment_field[0] %>_file_name, :string
      t.column :<%= attachment_field[0] %>_content_type, :string
      t.column :<%= attachment_field[0] %>_file_size, :integer
      t.column :<%= attachment_field[0] %>_updated_at, :datetime
<% elsif RxSettings.attachment_plugin == 'attachment_fu' -%>
      # For attachment_fu
      t.column :parent_id,  :integer
      t.column :content_type, :string
      t.column :filename, :string    
      t.column :thumbnail, :string 
      t.column :size, :integer
      t.column :width, :integer
      t.column :height, :integer
<% end -%>
<% end -%>
<% unless options[:skip_timestamps] %>
      t.timestamps
<% end -%>
    end
  end

  def self.down
    drop_table :<%= table_name %>
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
captproton-restfulx-1.2.3 rails_generators/rx_scaffold/templates/migration.rb.erb
dima-restfulx-1.2.3 rails_generators/rx_scaffold/templates/migration.rb.erb
restfulx-1.2.3 rails_generators/rx_scaffold/templates/migration.rb.erb