Sha256: 695c58c604f412886e117827643fec3c4b2e9490e4437e2bc065cfb30a323ab2

Contents?: true

Size: 980 Bytes

Versions: 3

Compression:

Stored size: 980 Bytes

Contents

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

  def self.up
    create_table :<%= 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.
    if attribute.type.to_s =~ /^(image|resource)$/
      attribute.type = 'integer'
      attribute.name = "#{attribute.name}_id".gsub("_id_id", "_id")
    end
-%>
      t.<%= attribute.type %> :<%= attribute.name %>
<% end -%>
      t.integer :position

      t.timestamps
    end

    add_index :<%= table_name %>, :id

    load(Rails.root.join('db', 'seeds', '<%= class_name.pluralize.underscore.downcase %>.rb'))
  end

  def self.down
    if defined?(UserPlugin)
      UserPlugin.destroy_all({:name => "<%= class_name.pluralize.underscore.downcase %>"})
    end

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

    drop_table :<%= table_name %>
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
refinerycms-generators-1.0.4 lib/generators/refinery_engine/templates/db/migrate/create_plural_name.rb
refinerycms-generators-1.0.3 lib/generators/refinery_engine/templates/db/migrate/create_plural_name.rb
refinerycms-generators-1.0.2 lib/generators/refinery_engine/templates/db/migrate/create_plural_name.rb