Class: MenuModelMigration

Inherits:
Migration show all
Defined in:
lib/yodel/models/migrations/14_menu_model.rb

Class Method Summary collapse

Methods inherited from Migration

copy_missing_migrations_for_all_sites, copy_missing_migrations_for_site, inherited, run_migrations, run_migrations_for_all_sites

Class Method Details

.down(site) ⇒ Object



17
18
19
# File 'lib/yodel/models/migrations/14_menu_model.rb', line 17

def self.down(site)
  site.menus.destroy
end

.up(site) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/yodel/models/migrations/14_menu_model.rb', line 2

def self.up(site)
  site.records.create_model :menu do |menus|
    add_one   :root, model: :page, validations: {required: {}}
    add_field :include_root, :boolean, default: false
    add_field :include_all_children, :boolean, default: true
    add_field :depth, :integer, default: 0, validations: {required: {}}
    add_embed_many :exceptions do
      add_one   :page
      add_field :show, :boolean, default: false
      add_field :depth, :integer, default: 0, validations: {required: {}}
    end
    menus.record_class_name = 'Menu'
  end
end