-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
33 lines (27 loc) · 948 Bytes
/
Copy pathschema.sql
File metadata and controls
33 lines (27 loc) · 948 Bytes
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
-- wirecache schema
-- Applied via: wirecache init (or automatically on first DB command)
CREATE TABLE IF NOT EXISTS stories (
id SERIAL PRIMARY KEY,
url TEXT UNIQUE NOT NULL,
title TEXT,
summary TEXT,
source TEXT,
categories TEXT[],
published TIMESTAMPTZ,
fetched_at TIMESTAMPTZ DEFAULT NOW(),
search_vector TSVECTOR GENERATED ALWAYS AS (
to_tsvector(
'english',
coalesce(title, '') || ' ' ||
coalesce(summary, '')
)
) STORED
);
CREATE INDEX IF NOT EXISTS stories_search_idx
ON stories USING GIN (search_vector);
CREATE INDEX IF NOT EXISTS stories_published_idx
ON stories (published DESC);
CREATE INDEX IF NOT EXISTS stories_categories_idx
ON stories USING GIN (categories);
CREATE INDEX IF NOT EXISTS stories_fetched_idx
ON stories (fetched_at);