Class: CreatePages

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

Class Method Summary collapse

Class Method Details

.downObject



25
26
27
# File 'lib/generators/templates/create_pages.rb', line 25

def self.down
  drop_table :pages
end

.upObject



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

def self.up
  create_table :pages, :force => true do |t|
    t.string :title
    t.text :body
    t.string :slug
    t.publishable
    t.timestamps

    t.integer :likes_count, :default => 0
    t.integer :votes_count, :default => 0

    t.integer :parent_id
    t.integer :position, :default => 0

    t.integer :post_id
  end
  add_index :pages, :slug
  add_index :pages, :likes_count
  add_index :pages, :votes_count
  add_index :pages, :parent_id
  add_index :pages, :post_id
end