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)


148
149
150
# File 'lib/pluto/schema.rb', line 148

def down
  raise ActiveRecord::IrreversibleMigration
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/pluto/schema.rb', line 7

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

    t.string   :author    # owner_name, author_name
    t.string   :email     # owner_email, author_email
    t.datetime :updated   # date for subscription list last updated via pluto

    ############
    # filters (site-wide)
    t.string   :includes  # regex
    t.string   :excludes  # regex


    ######################
    # for auto-update of feed list/site config

    t.string   :url    # source url for auto-update (optional)

    ## note: make sure to use same fields for update check as feed

    t.datetime :fetched   #  date for last fetched/checked for feeds via pluto -- make not null ??
    t.integer  :http_code   # last http status code e.g. 200,404,etc.
    t.string   :http_etag    # last http header etag
    ## note: save last-modified header as text (not datetime) - pass through as is
    t.string   :http_last_modified   # last http header last-modified - note: save header as plain text!!! pass along in next request as-is
    t.string   :http_server    # last http server header if present

    # note: do NOT store body content (that is, text) and md5 digest
    #   use git! and github! commit will be http_etag!!


    #############
    # more fields

    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  :key,       null: false
    t.string  :encoding,  null: false, default: 'utf8'  # charset encoding; default to utf8
    t.string  :format      # e.g. atom (1.0), rss 2.0, rss 0.7 etc.

    t.string  :title        # user supplied title
    t.string  :auto_title   # "fallback" - auto(fill) title from feed

    t.string  :title2        # user supplied title2
    t.string  :auto_title2   # "fallback" - auto(fill) title2 from feed e.g. subtitle (atom)

    t.string  :url          # user supplied site url
    t.string  :auto_url     # "fallback" - auto(fill) url from feed

    t.string  :feed_url       # user supplied feed url
    t.string  :auto_feed_url  # "fallback" - auto discovery feed url from (site) url

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

    t.string  :generator   # feed generator (e.g. wordpress, etc.)  from feed
    
    t.datetime :published  # from feed published(atom)+ pubDate(rss)
    t.datetime :built      # from feed lastBuiltDate(rss)
    t.datetime :touched    # from feed updated(atom)


    ### extras (move to array for custom fields or similar??)
    t.string   :author   # author_name, owner_name
    t.string   :email    # author_email, owner_email
    t.string   :avatar   # gravator or hackergotchi handle (optional)

    t.string   :github   # github handle  (optional)
    t.string   :twitter  # twitter handle (optional)
    t.string   :meetup   # meetup handle (optional)


    ### add class/kind field e.g.
    # - personal feed/blog/site, that is, individual author
    # - team blog/site
    # - org (anization) or com(pany blog/site)
    # - newsfeed (composite)
    # - other  (link blog?, podcast?) - why? why not??

    ############
    # filters (feed-wide)
    t.string   :includes  # regex
    t.string   :excludes  # regex
    # todo: add generic filter list e.g. t.string :filters  (comma,pipe or space separated method names?)

    # -- our own (meta) fields
    t.datetime :last_published  # cache last (latest) published for items - e.g. latest date from publisehd item
    t.datetime :fetched    # last fetched date via pluto

    t.integer  :http_code   # last http status code e.g. 200,404,etc.
    t.string   :http_etag    # last http header etag
    ## note: save last-modified header as text (not datetime) - pass through as is
    t.string   :http_last_modified   # last http header last-modified - note: save header as plain text!!! pass along in next request as-is
    t.string   :http_server    # last http server header if present

    t.string   :md5       # md5 hash of body
    t.text     :body      # last http response body (complete feed!)


    t.timestamps   # created_at, updated_at
  end


  create_table :items do |t|
    t.string   :guid
    t.string   :url

    ## note: title may contain more than 255 chars!!
    ## e.g. Rails Girls blog has massive titles in feed
    ## cut-off/limit to 255
    ##  also strip tags in titles - why? why not?? - see feed.title2/auto_title2

    t.string   :title   # todo: add some :null => false ??
    t.text     :summary  # e.g. description (rss), summary (atom)
    t.text     :content

    t.datetime :published   # from feed (published)  + pubDate(rss)
    t.datetime :touched     # 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   # last fetched/check date via pluto
    t.timestamps   # created_at, updated_at

    ## t.string   :author
    ## todo: add author/authors, category/categories
  end

end