Sha256: 93ccd54f3885a220907f404d075819c9f4e42d7ba7b5ad1e13a3efb13e60b287

Contents?: true

Size: 861 Bytes

Versions: 2

Compression:

Stored size: 861 Bytes

Contents

class ConvertPageMetas < ActiveRecord::Migration
  def self.up
    # following add and remove column enables running this migration 
    # when upgrading radiant with allowed_children_cache added to Page model
    add_column :pages, :allowed_children_cache, :text
    Page.all.each do |page|
      page.fields.create(:name => 'Keywords', :content => page.keywords)
      page.fields.create(:name => 'Description', :content => page.description)
    end
    remove_column :pages, :keywords
    remove_column :pages, :description
    remove_column :pages, :allowed_children_cache
  end

  def self.down
    add_column :pages, :description, :string
    add_column :pages, :keywords, :string
    Page.all.each do |page|
      page.description = page.field('description').content
      page.keywords = page.field('keywords').content
      page.save
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
trusty-cms-1.0.0 db/migrate/20100805155020_convert_page_metas.rb
radiant-1.1.4 db/migrate/20100805155020_convert_page_metas.rb