Skip to content

Commit 5eace78

Browse files
committed
Convert indexes to primary keys
1 parent 3ad30c3 commit 5eace78

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

sql/pg.sql

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ CREATE INDEX i_rosteru_jid ON rosterusers USING btree (jid);
5757
CREATE TABLE rostergroups (
5858
username text NOT NULL,
5959
jid text NOT NULL,
60-
grp text NOT NULL
60+
grp text NOT NULL,
61+
PRIMARY KEY (username, jid, grp)
6162
);
6263

63-
CREATE INDEX pk_rosterg_user_jid ON rostergroups USING btree (username, jid);
64-
6564
CREATE TABLE sr_group (
6665
name text NOT NULL,
6766
opts text NOT NULL,
@@ -82,7 +81,7 @@ CREATE INDEX i_sr_user_grp ON sr_user USING btree (grp);
8281
CREATE TABLE spool (
8382
username text NOT NULL,
8483
xml text NOT NULL,
85-
seq BIGSERIAL,
84+
seq BIGSERIAL PRIMARY KEY,
8685
created_at TIMESTAMP NOT NULL DEFAULT now()
8786
);
8887

@@ -95,7 +94,7 @@ CREATE TABLE archive (
9594
bare_peer text NOT NULL,
9695
xml text NOT NULL,
9796
txt text,
98-
id BIGSERIAL,
97+
id BIGSERIAL PRIMARY KEY,
9998
kind text,
10099
nick text,
101100
created_at TIMESTAMP NOT NULL DEFAULT now()
@@ -174,6 +173,7 @@ CREATE TABLE privacy_list (
174173
CREATE UNIQUE INDEX i_privacy_list_username_name ON privacy_list USING btree (username, name);
175174

176175
CREATE TABLE privacy_list_data (
176+
seq BIGSERIAL PRIMARY KEY,
177177
id bigint REFERENCES privacy_list(id) ON DELETE CASCADE,
178178
t character(1) NOT NULL,
179179
value text NOT NULL,
@@ -228,15 +228,14 @@ CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node);
228228
CREATE TABLE pubsub_node_option (
229229
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
230230
name text NOT NULL,
231-
val text NOT NULL
231+
val text NOT NULL,
232+
PRIMARY KEY (nodeid, name)
232233
);
233-
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option USING btree (nodeid);
234234

235235
CREATE TABLE pubsub_node_owner (
236-
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
236+
nodeid bigint PRIMARY KEY REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
237237
owner text NOT NULL
238238
);
239-
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner USING btree (nodeid);
240239

241240
CREATE TABLE pubsub_state (
242241
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
@@ -329,11 +328,10 @@ CREATE TABLE caps_features (
329328
node text NOT NULL,
330329
subnode text NOT NULL,
331330
feature text,
332-
created_at TIMESTAMP NOT NULL DEFAULT now()
331+
created_at TIMESTAMP NOT NULL DEFAULT now(),
332+
PRIMARY KEY (node, subnode, feature)
333333
);
334334

335-
CREATE INDEX i_caps_features_node_subnode ON caps_features USING btree (node, subnode);
336-
337335
CREATE TABLE sm (
338336
usec bigint NOT NULL,
339337
pid text NOT NULL,

0 commit comments

Comments
 (0)