-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
76 lines (61 loc) · 3.35 KB
/
schema.sql
File metadata and controls
76 lines (61 loc) · 3.35 KB
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
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
-- links table stores URLs and its last accessed timestamp (for re-crawling purposes)
create table links (
url text not null unique primary key,
last_enqueued_at timestamp not null default current_timestamp,
created_at timestamp not null default current_timestamp
);
create index idx_links_last_enqueued_at on links (last_enqueued_at);
create index idx_links_created_at on links (created_at);
-- blog_users table stores users of the blog platforms for re-crawling purposes
create table blog_users (
blog_platform text not null,
user_id text not null,
last_enqueued_at timestamp not null default current_timestamp,
created_at timestamp not null default current_timestamp,
primary key (blog_platform, user_id)
);
create index idx_blog_users_last_enqueued_at on blog_users (last_enqueued_at);
create index idx_blog_users_created_at on blog_users (created_at);
-- blog_posts table stores blog posts' path and metadata
create table blog_posts (
blog_platform text not null,
post_url text not null,
path text not null,
published_at timestamp,
created_at timestamp not null default current_timestamp,
updated_at timestamp not null default current_timestamp,
primary key (post_url)
);
create index idx_blog_posts_created_at on blog_posts (created_at);
create index idx_blog_posts_updated_at on blog_posts (updated_at);
-- task queues stores backlog of tasks to be processed
-- fetch content
create table content_queue (
id bigserial primary key,
payload text not null,
enqueued_at timestamp not null default current_timestamp,
locked_until timestamp,
attempts integer not null default 0,
status text not null default 'waiting' -- waiting, processing, done, failed
);
create index idx_content_queue_enqueued_at on content_queue (enqueued_at);
-- fetch related profiles
create table profile_queue (
id bigserial primary key,
payload text not null,
enqueued_at timestamp not null default current_timestamp,
locked_until timestamp,
attempts integer not null default 0,
status text not null default 'waiting' -- waiting, processing, done, failed
);
create index idx_profile_queue_enqueued_at on profile_queue (enqueued_at);
-- fetch user data
create table user_queue (
id bigserial primary key,
payload text not null,
enqueued_at timestamp not null default current_timestamp,
locked_until timestamp,
attempts integer not null default 0,
status text not null default 'waiting' -- waiting, processing, done, failed
);
create index idx_user_queue_enqueued_at on user_queue (enqueued_at);