Class: SunriseCreateStructures

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/sunrise/templates/migrate/create_structures.rb

Class Method Summary collapse

Class Method Details

.downObject



24
25
26
# File 'lib/generators/sunrise/templates/migrate/create_structures.rb', line 24

def self.down
  drop_table :structures
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/sunrise/templates/migrate/create_structures.rb', line 2

def self.up
  create_table :structures do |t|
    t.string    :title, :null => false
    t.string    :slug, :null => false, :limit => 25
    t.integer   :kind, :limit => 1, :default => 0
    t.integer   :position, :limit => 2, :default => 0
    t.boolean   :is_visible, :default => true
    t.string    :redirect_url
    
    t.integer  "parent_id"
    t.integer  "lft",                          :default => 0
    t.integer  "rgt",                          :default => 0
    t.integer  "depth",                        :default => 0
    
    t.timestamps
  end
  
  add_index :structures, [:kind, :slug], :uniq => true
  add_index :structures, :parent_id
  add_index :structures, [:lft, :rgt]
end