Mercurial > libervia-pubsub
annotate db/pubsub.sql @ 215:aecfacb5a571
Remove debugging prints.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Thu, 18 Jun 2009 13:11:59 +0000 |
parents | 274a45d2a5ab |
children | 70c8bb90d75f |
rev | line source |
---|---|
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
1 CREATE TABLE entities ( |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
2 entity_id serial PRIMARY KEY, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
3 jid text NOT NULL UNIQUE |
87 | 4 ); |
5 | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
6 CREATE TABLE nodes ( |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
7 node_id serial PRIMARY KEY, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
8 node text NOT NULL UNIQUE, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
9 node_type text NOT NULL DEFAULT 'leaf' |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
10 CHECK (node_type IN ('leaf', 'collection')), |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
11 persist_items boolean, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
12 deliver_payloads boolean NOT NULL DEFAULT TRUE, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
13 send_last_published_item text NOT NULL DEFAULT 'on_sub' |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
14 CHECK (send_last_published_item IN ('never', 'on_sub')) |
87 | 15 ); |
16 | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
17 INSERT INTO nodes (node, node_type) values ('', 'collection'); |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
18 |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
19 CREATE TABLE affiliations ( |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
20 affiliation_id serial PRIMARY KEY, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
21 entity_id integer NOT NULL REFERENCES entities ON DELETE CASCADE, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
22 node_id integer NOT NULL references nodes ON DELETE CASCADE, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
23 affiliation text NOT NULL |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
24 CHECK (affiliation IN ('outcast', 'publisher', 'owner')), |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
25 UNIQUE (entity_id, node_id) |
87 | 26 ); |
27 | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
28 CREATE TABLE subscriptions ( |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
29 subscription_id serial PRIMARY KEY, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
30 entity_id integer NOT NULL REFERENCES entities ON DELETE CASCADE, |
87 | 31 resource text, |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
32 node_id integer NOT NULL REFERENCES nodes ON delete CASCADE, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
33 state text NOT NULL DEFAULT 'subscribed' |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
34 CHECK (state IN ('subscribed', 'pending', 'unconfigured')), |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
35 subscription_type text |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
36 CHECK (subscription_type IN (NULL, 'items', 'nodes')), |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
37 subscription_depth text |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
38 CHECK (subscription_depth IN (NULL, '1', 'all')), |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
39 UNIQUE (entity_id, resource, node_id)); |
87 | 40 |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
41 CREATE TABLE items ( |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
42 item_id serial PRIMARY KEY, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
43 node_id integer NOT NULL REFERENCES nodes ON DELETE CASCADE, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
44 item text NOT NULL, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
45 publisher text NOT NULL, |
87 | 46 data text, |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
47 date timestamp with time zone NOT NULL DEFAULT now(), |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
188
diff
changeset
|
48 UNIQUE (node_id, item) |
87 | 49 ); |