Class: BlogAddAttachmentsToArticleMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/04_add_attachment_to_article.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/migrations/04_add_attachment_to_article.rb', line 13

def self.down(site)
  site.pages.create_model :articles do |articles|
    add_field :blog, :alias, of: :parent
    remove_field :attachment
  end
  
  site.blogs.create_model :articles do |articles|
    add_field :blog, :alias, of: :parent
  end
end

.up(site) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/migrations/04_add_attachment_to_article.rb', line 2

def self.up(site)
  site.articles.modify do |articles|
    add_field :attachment, :attachment
    remove_field :blog
  end
  
  site.blogs.modify do |articles|
    remove_field :blog
  end
end