Sha256: 4740664db2b414f6ceefb26f02e6810464a3c535706c831731bec05a35b64ef6

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

class <%= migration_name %> < ActiveRecord::Migration

  def self.up
    create_table :<%= table_name %> do |t|
<% attributes.each do |attribute| -%>
      t.<%= attribute.type %> :<%= attribute.name %>
<% end -%>
      t.timestamps
    end

    add_index :<%= table_name %>, :id

    User.find(:all).each do |user|
      user.plugins.create(:title => "News", :position => (user.plugins.maximum(:position) || -1) + 1)
    end

    page = Page.create(:title => "News",
                :link_url => "/news",
                :menu_match => "^/news.*$",
                :deletable => false,
                :position => Page.count)

    RefinerySetting.find_or_set(:default_page_parts, ["Body", "Side Body"]).each do |default_page_part|
      page.parts.create(:title => default_page_part, :body => nil)
    end

  end

  def self.down
    UserPlugin.destroy_all({:title => "News"})

    Page.find_all_by_link_url("/news").each do |page|
      page.link_url, page.menu_match = nil
      page.deletable = true
      page.destroy
    end
    Page.destroy_all({:link_url => "/news"})

    drop_table :<%= table_name %>
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
refinerycms-news-0.9.7.1 generators/news/templates/migration.rb
sneakin-refinerycms-news-0.9.7.2 generators/news/templates/migration.rb
sneakin-refinerycms-news-0.9.7.1 generators/news/templates/migration.rb
refinerycms-news-0.9.7 generators/news/templates/migration.rb