Sha256: 4ba95ba85e8a22cb9608c396895c8207181bc560882ea50a7f32f53ce894fa95

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 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 :avatar_file_name, :string
      t.column :avatar_content_type, :string
      t.column :avatar_file_size, :integer
      t.column :avatar_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

2 entries across 2 versions & 2 rubygems

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