Sha256: 806f068d42a610311781e69aa41ec2468bd66cdc6c505c3b3d96768f7d3d3eb3

Contents?: true

Size: 981 Bytes

Versions: 6

Compression:

Stored size: 981 Bytes

Contents

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

  def up
    create_table :refinery_<%= table_name %> do |t|
<%
  attributes.each do |attribute|
    # turn image or resource into what it was supposed to be which is an integer reference to an image or resource.
    case attribute.type
    when :image, :resource
      attribute.type = 'integer'
      attribute.name = "#{attribute.name}_id"
    when :radio, :select
      attribute.type = 'string'
    when :checkbox
      attribute.type = 'boolean'
    end
-%>
      t.<%= attribute.type %> :<%= attribute.name %>
<% 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

6 entries across 6 versions & 1 rubygems

Version Path
refinerycms-core-2.1.5 lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb
refinerycms-core-2.1.4 lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb
refinerycms-core-2.1.3 lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb
refinerycms-core-2.1.2 lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb
refinerycms-core-2.1.1 lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb
refinerycms-core-2.1.0 lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb