Skip to content

Commit f1bf58d

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

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

sql/pg.sql

Lines changed: 10 additions & 15 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)
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,7 +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 (
177-
id bigint REFERENCES privacy_list(id) ON DELETE CASCADE,
176+
id bigint PRIMARY KEY REFERENCES privacy_list(id) ON DELETE CASCADE,
178177
t character(1) NOT NULL,
179178
value text NOT NULL,
180179
action character(1) NOT NULL,
@@ -186,8 +185,6 @@ CREATE TABLE privacy_list_data (
186185
match_presence_out boolean NOT NULL
187186
);
188187

189-
CREATE INDEX i_privacy_list_data_id ON privacy_list_data USING btree (id);
190-
191188
CREATE TABLE private_storage (
192189
username text NOT NULL,
193190
namespace text NOT NULL,
@@ -228,15 +225,14 @@ CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node);
228225
CREATE TABLE pubsub_node_option (
229226
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
230227
name text NOT NULL,
231-
val text NOT NULL
228+
val text NOT NULL,
229+
PRIMARY KEY (nodeid, name)
232230
);
233-
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option USING btree (nodeid);
234231

235232
CREATE TABLE pubsub_node_owner (
236-
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
233+
nodeid bigint PRIMARY KEY REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
237234
owner text NOT NULL
238235
);
239-
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner USING btree (nodeid);
240236

241237
CREATE TABLE pubsub_state (
242238
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
@@ -329,11 +325,10 @@ CREATE TABLE caps_features (
329325
node text NOT NULL,
330326
subnode text NOT NULL,
331327
feature text,
332-
created_at TIMESTAMP NOT NULL DEFAULT now()
328+
created_at TIMESTAMP NOT NULL DEFAULT now(),
329+
PRIMARY KEY (node, subnode, feature)
333330
);
334331

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

0 commit comments

Comments
 (0)