tables.sql 2.79 KB
Newer Older
David Morley's avatar
David Morley committed
1 2 3
CREATE TABLE pods (
 id serial8 UNIQUE PRIMARY KEY,
 domain text UNIQUE NOT NULL,
4
 name text,
5
 softwarename text,
dmorley's avatar
dmorley committed
6 7
 masterversion text,
 shortversion text,
8
 stats_apikey text,
9 10 11
 score int DEFAULT 50,
 weightedscore numeric(5,2) DEFAULT 0,
 userrating decimal DEFAULT 0,
12
 ip text,
13
 detectedlanguage text,
14
 country text,
15
 countryname text,
16 17 18 19
 city text,
 state text, 
 lat text,
 long text,
David Morley's avatar
David Morley committed
20
 email text,
dmorley's avatar
dmorley committed
21
 ipv6 boolean,
David Morley's avatar
David Morley committed
22 23
 sslvalid text,
 monthsmonitored int,
24
 daysmonitored int,
dmorley's avatar
dmorley committed
25
 signup boolean,
26 27 28 29
 total_users int, 
 active_users_halfyear int,
 active_users_monthly int,
 local_posts int,
dmorley's avatar
dmorley committed
30
 uptime_alltime numeric(5,2),
dmorley's avatar
dmorley committed
31
 status smallint DEFAULT 1,
dmorley's avatar
latent  
dmorley committed
32
 latency smallint,
dmorley's avatar
dmorley committed
33
 service_xmpp boolean,
dmorley's avatar
dmorley committed
34
 services jsonb,
dmorley's avatar
dmorley committed
35
 protocols jsonb,
dmorley's avatar
dmorley committed
36
 token text,
David Morley's avatar
David Morley committed
37
 publickey text,
dmorley's avatar
dmorley committed
38
 tokenexpire timestamp,
David Morley's avatar
David Morley committed
39
 podmin_statement text,
40
 podmin_notify boolean,
dmorley's avatar
dmorley committed
41
 podmin_notify_level int DEFAULT 50,
dmorley's avatar
dmorley committed
42 43
 sslexpire timestamp,
 dnssec boolean,
44
 comment_counts int,
45
 weight int DEFAULT 10,
dmorley's avatar
dmorley committed
46 47 48
 date_updated timestamp DEFAULT current_timestamp,
 date_laststats timestamp DEFAULT current_timestamp,
 date_created timestamp DEFAULT current_timestamp
David Morley's avatar
David Morley committed
49
);
dmorley's avatar
dmorley committed
50

51
CREATE TABLE ratingcomments (
David Morley's avatar
David Morley committed
52 53 54 55
 id serial8 UNIQUE PRIMARY KEY,
 domain text NOT NULL,
 comment text,
 pod_id int,
56 57
 rating int,
 username text,
58
 date_created timestamp DEFAULT current_timestamp
59
);
dmorley's avatar
dmorley committed
60

dmorley's avatar
dmorley committed
61
CREATE TABLE apikeys (
noplanman's avatar
noplanman committed
62
 id serial8 UNIQUE PRIMARY KEY,
dmorley's avatar
dmorley committed
63 64 65
 key text,
 email text,
 usage int,
dmorley's avatar
dmorley committed
66
 date_created timestamp DEFAULT current_timestamp
dmorley's avatar
dmorley committed
67 68 69
);

CREATE TABLE clicks (
noplanman's avatar
noplanman committed
70
 id serial8 UNIQUE PRIMARY KEY,
dmorley's avatar
dmorley committed
71 72 73
 domain text,
 manualclick int,
 autoclick int,
dmorley's avatar
dmorley committed
74
 date_clicked timestamp DEFAULT current_timestamp
dmorley's avatar
dmorley committed
75 76 77
);

CREATE TABLE checks (
noplanman's avatar
noplanman committed
78
 id serial8 UNIQUE PRIMARY KEY,
dmorley's avatar
dmorley committed
79 80 81
 domain text,
 online boolean,
 error text,
dmorley's avatar
latent  
dmorley committed
82
 latency numeric(8,6),
David Morley's avatar
David Morley committed
83 84 85 86
 total_users int,
 local_posts int,
 comment_counts int,
 shortversion text,
dmorley's avatar
dmorley committed
87
 version text,
David Morley's avatar
David Morley committed
88 89 90 91
 date_checked timestamp DEFAULT current_timestamp
);

CREATE TABLE masterversions (
noplanman's avatar
noplanman committed
92
 id serial8 UNIQUE PRIMARY KEY,
David Morley's avatar
David Morley committed
93 94
 software text,
 version text,
95 96
 devlastcommit timestamp,
 releasedate timestamp,
dmorley's avatar
dmorley committed
97
 date_checked timestamp DEFAULT current_timestamp
dmorley's avatar
dmorley committed
98
);
dmorley's avatar
dmorley committed
99

dmorley's avatar
dmorley committed
100 101 102 103 104 105 106 107 108 109
CREATE TABLE monthlystats (
 id serial8 UNIQUE PRIMARY KEY,
 total_users int,
 total_posts int,
 total_comments int,
 total_pods int,
 total_uptime int,
 date_checked timestamp DEFAULT current_timestamp
);

dmorley's avatar
dmorley committed
110
CREATE TABLE meta (
dmorley's avatar
dmorley committed
111
 id serial8 UNIQUE PRIMARY KEY,
dmorley's avatar
dmorley committed
112 113 114
 name text,
 value text,
 date_created timestamp DEFAULT current_timestamp
dmorley's avatar
dmorley committed
115
);
dmorley's avatar
dmorley committed
116 117 118 119 120 121 122 123
INSERT INTO meta (name) VALUES('languages_updated');
INSERT INTO meta (name) VALUES('cacert_updated');
INSERT INTO meta (name) VALUES('geoip_updated');
INSERT INTO meta (name) VALUES('masterversions_updated');
INSERT INTO meta (name) VALUES('federation_updated');
INSERT INTO meta (name) VALUES('statstable_updated');
INSERT INTO meta (name) VALUES('backup');
INSERT INTO meta (name) VALUES('pods_updated');
124
INSERT INTO meta (name) VALUES('sitemap_updated');