cirandas.net

ref: master

db/migrate/019_create_comments.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class CreateComments < ActiveRecord::Migration
  def self.up
    create_table :comments do |t|

      # acts as filesystem
      t.column :title, :string
      t.column :body, :text

      # belongs to an article
      t.column :article_id, :integer

      # belongs to a person, maybe unauthenticated
      t.column :author_id, :integer
      t.column :name, :string
      t.column :email, :string

      # keep track of changes
      t.column :created_on,  :datetime 
    end

  end

  def self.down
    drop_table :comments
  end
end