Class: Pluto::CreateDb

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/pluto/schema.rb

Instance Method Summary collapse

Instance Method Details

#downObject

Raises:

  • (ActiveRecord::IrreversibleMigration)


38
39
40
# File 'lib/pluto/schema.rb', line 38

def down
  raise ActiveRecord::IrreversibleMigration
end

#upObject



6
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
# File 'lib/pluto/schema.rb', line 6

def up
  create_table :sites do |t|
    t.string  :title,    :null => false    # e.g Planet Ruby, Planet JavaScript, etc.
    t.string  :key,      :null => false    # e.g. ruby, js, etc.
    t.timestamps
  end

  create_table :subscriptions do |t|   # has_many join table (sites/feeds)
    t.references :site, :null => false
    t.references :feed, :null => false
    t.timestamps
  end

  create_table :feeds do |t|
    t.string  :title,    :null => false
    t.string  :url,      :null => false
    t.string  :feed_url, :null => false
    t.string  :key,      :null => false
    t.timestamps
  end

  create_table :items do |t|
    t.string   :title   # todo: add some :null => false ??
    t.string   :url
    t.string   :guid
    t.text     :content
    t.datetime :published_at
    t.references :feed, :null => false
    t.timestamps
  end
end