Class: CortexReaver::CommentSchema

Inherits:
Sequel::Migration
  • Object
show all
Defined in:
lib/cortex_reaver/migrations/007_comments.rb

Instance Method Summary collapse

Instance Method Details

#downObject



3
4
5
# File 'lib/cortex_reaver/migrations/007_comments.rb', line 3

def down
  drop_table :comments if table_exists? :comments
end

#upObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cortex_reaver/migrations/007_comments.rb', line 7

def up
  unless table_exists? :comments
    create_table :comments do
      primary_key :id

      foreign_key :user_id, :table => :users
      index :user_id

      foreign_key :journal_id, :table => :journals
      index :journal_id
      foreign_key :photograph_id, :table => :photographs
      index :photograph_id
      foreign_key :project_id, :table => :projects
      index :project_id
      foreign_key :comment_id, :table => :comments
      index :comment_id
      foreign_key :page_id, :table => :pages
      index :page_id

      varchar :title
      text :name
      text :http
      text :email
      text :body, :default => ''
      text :body_cache, :default => ''
      integer :comment_count, :null => false, :default => 0

      datetime :created_on
      datetime :updated_on
    end
  end
end