Skip to content

Commit e238a60

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

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

sql/pg.sql

Lines changed: 9 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,
@@ -226,17 +223,15 @@ CREATE INDEX i_pubsub_node_parent ON pubsub_node USING btree (parent);
226223
CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node);
227224

228225
CREATE TABLE pubsub_node_option (
229-
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
226+
nodeid bigint PRIMARY KEY REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
230227
name text NOT NULL,
231228
val text NOT NULL
232229
);
233-
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option USING btree (nodeid);
234230

235231
CREATE TABLE pubsub_node_owner (
236-
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
232+
nodeid bigint PRIMARY KEY REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
237233
owner text NOT NULL
238234
);
239-
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner USING btree (nodeid);
240235

241236
CREATE TABLE pubsub_state (
242237
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
@@ -329,11 +324,10 @@ CREATE TABLE caps_features (
329324
node text NOT NULL,
330325
subnode text NOT NULL,
331326
feature text,
332-
created_at TIMESTAMP NOT NULL DEFAULT now()
327+
created_at TIMESTAMP NOT NULL DEFAULT now(),
328+
PRIMARY KEY (node, subnode, feature)
333329
);
334330

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

0 commit comments

Comments
 (0)