Sha256: 70dc3958cd0789eef9e8ad6f2247cc28c94d5f0927a48631335546847417677d

Contents?: true

Size: 1.6 KB

Versions: 3

Compression:

Stored size: 1.6 KB

Contents

class PageModelMigration < Migration
  def self.up(site)
    site.records.create_model :pages do |pages|
      # core page attributes
      add_field :permalink, :string, validations: {required: {}}, index: true, searchable: false, display: false
      add_field :path, :string, validations: {required: {}}, index: true, searchable: false, display: false
      add_field :created_at, :time, display: false
      add_field :title, :string, validations: {required: {}}
      add_field :content, :html
      
      # options section
      add_field :show_in_menus, :boolean, default: true, section: 'Options'
      add_field :description, :text, section: 'Options', searchable: false
      add_field :keywords, :text, section: 'Options', searchable: false
      add_field :custom_meta_tags, :text, section: 'Options', searchable: false
      add_one   :new_child_page, model: :page, section: 'Options', show_blank: true, blank_text: 'None'
      
      # layout
      add_field :page_layout, :string, section: 'Options', default: nil, searchable: false
      add_one   :page_layout_record, model: :layout, display: false
      add_field :edit_layout, :string, searchable: false, section: 'Options'
      add_one   :edit_layout_record, model: :layout, display: false
      
      add_field :name, :alias, of: :title
      pages.default_child_model = pages.id
      pages.allowed_children = [pages]
      pages.allowed_parents = [pages]
      pages.record_class_name = 'Page'
    end
    
    # default root page
    page = site.pages.new
    page.title = "Home"
    page.save
  end
  
  def self.down(site)
    site.pages.destroy
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yodel_development_environment-0.0.4 lib/migrations/yodel/02_page_model.rb
yodel_development_environment-0.0.2 lib/migrations/yodel/02_page_model.rb
yodel_development_environment-0.0.1 lib/migrations/yodel/02_page_model.rb