Sha256: 78d38008086fb2c2ff7bd7773a7cfd00d229759cd2aafdd1886d7689da90735f

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

class Create<%= class_name.pluralize %> < ActiveRecord::Migration

  def up
    create_table :refinery_<%= table_name %> do |t|
<% attributes.each do |attribute| -%>
      t.<%= attribute.type %> :<%= attribute.column_name %>
<% end -%>
<% if include_spam? %>
       t.boolean :spam, :default => false
     <% end %>
     t.timestamps
    end

    add_index :refinery_<%= table_name %>, :id
  end

  def down
    if defined?(::Refinery::UserPlugin)
      ::Refinery::UserPlugin.destroy_all({:name => "<%= plural_name %>"})
    end

    if defined?(::Refinery::Page)
      ::Refinery::Page.delete_all({:link_url => "/<%= plural_name %>"})
    end

    drop_table :refinery_<%= table_name %>
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
refinerycms-forms-1.0.1 lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb
refinerycms-forms-1.0.0 lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb