-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.sql
More file actions
64 lines (55 loc) · 1.93 KB
/
Copy pathdb.sql
File metadata and controls
64 lines (55 loc) · 1.93 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
-- DROP TABLE comment;
CREATE TABLE comment (
comment_id bigserial NOT NULL,
graph_id bigint,
object_id bigint,
ts timestamp without time zone,
msg text,
CONSTRAINT comment_pkey PRIMARY KEY (comment_id)
) WITH (OIDS=FALSE);
-- DROP INDEX comment_graph_id_and_ts;
CREATE INDEX comment_ts ON comment USING btree (ts);
CREATE INDEX comment_graph_id_and_ts ON comment USING btree (graph_id, ts);
CREATE INDEX comment_graph_id_and_ts_and_object_id ON comment USING btree (graph_id, ts, object_id);
-- DROP TABLE data;
CREATE TABLE data (
data_id bigserial NOT NULL,
graph_id bigint,
ts timestamp without time zone,
value double precision,
object_id bigint,
amount bigint,
CONSTRAINT data_pkey PRIMARY KEY (data_id)
) WITH (OIDS=FALSE);
-- DROP INDEX data_graph_id_and_ts;
CREATE INDEX data_graph_id_and_ts ON data USING btree (graph_id, ts);
CREATE INDEX data_graph_id_and_ts_and_object_id ON data using btree (graph_id, ts, object_id);
CREATE TABLE meta (
meta_id BIGSERIAL NOT NULL,
graph_id bigint,
ts timestamp without time zone,
value text,
object_id double precision,
CONSTRAINT meta_pkey PRIMARY KEY (meta_id)
);
CREATE INDEX meta_graph_id_and_ts ON data USING btree (graph_id, ts);
CREATE INDEX meta_graph_id_and_ts_and_object_id ON data USING btree (graph_id, ts, object_id);
-- DROP TABLE graph;
CREATE TABLE graph (
graph_id bigserial NOT NULL,
title character varying(255),
added_at timestamp without time zone,
updated_at timestamp without time zone,
CONSTRAINT graph_pkey PRIMARY KEY (graph_id)
) WITH ( OIDS=FALSE );
-- DROP INDEX graph_updated_at;
CREATE INDEX graph_updated_at ON graph USING btree (updated_at);
CREATE TABLE collection(
collection_id BIGSERIAL NOT NULL,
title varchar(255),
added_at timestamp without time zone,
updated_at timestamp without time zone,
structure text,
CONSTRAINT collection_pkey PRIMARY KEY (collection_id)
);
CREATE INDEX collection_title ON collection USING btree (title);