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)


70
71
72
# File 'lib/pluto/schema.rb', line 70

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 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.datetime :fetched_at   #  last fetched/checked date -- make not null ??


    t.timestamps  # created_at, updated_at

  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  :title2     # e.g. subtitle (atom)

    t.text    :summary    # e.g. description (rss)

    t.string  :url,      :null => false
    t.string  :feed_url, :null => false
    t.string  :generator   # feed generator (e.g. wordpress, etc.)  from feed

    
    t.datetime :published_at  # from feed published(atom)+ pubDate(rss)

    t.datetime :built_at      # from feed lastBuiltDate(rss)

    t.datetime :touched_at    # from feed updated(atom)


    # -- our own (meta) fields

    t.string  :key,      :null => false
    t.string  :format      # e.g. atom (1.0), rss 2.0, rss 0.7 etc.

    t.string  :etag      # last etag

    t.datetime :fetched_at    # last fetched/checked date

    t.timestamps   # created_at, updated_at

  end

  create_table :items do |t|
    t.string   :title   # todo: add some :null => false ??

    t.string   :guid
    t.string   :url
    t.text     :summary  # e.g. description (rss), summary (atom)

    t.text     :content
    
    t.datetime :published_at   # from feed (published)  + pubDate(rss)

    t.datetime :touched_at     # from feed updated (atom)


    ## todo: add :last_updated_at ??  (NOTE: updated_at already take by auto-timestamps)

    t.references :feed, :null => false

    t.datetime :fetched_at   # last fetched/check date

    t.timestamps   # created_at, updated_at

    
    ## t.string   :author

    ## todo: add author/authors, category/categories

  end

  create_table :actions do |t|
    t.string   :title                # e.g. new site, new subscription, update feeds, etc.

    t.string   :object            # todo: find better names for action attribs ??

    t.string   :object_type
    t.timestamps
  end
  
end