Skip to content

Commit

Permalink
Convert indexes to primary keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mzealey committed Nov 3, 2023
1 parent 3ad30c3 commit f1bf58d
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions sql/pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ CREATE INDEX i_rosteru_jid ON rosterusers USING btree (jid);
CREATE TABLE rostergroups (
username text NOT NULL,
jid text NOT NULL,
grp text NOT NULL
grp text NOT NULL,
PRIMARY KEY (username, jid)
);

CREATE INDEX pk_rosterg_user_jid ON rostergroups USING btree (username, jid);

CREATE TABLE sr_group (
name text NOT NULL,
opts text NOT NULL,
Expand All @@ -82,7 +81,7 @@ CREATE INDEX i_sr_user_grp ON sr_user USING btree (grp);
CREATE TABLE spool (
username text NOT NULL,
xml text NOT NULL,
seq BIGSERIAL,
seq BIGSERIAL PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT now()
);

Expand All @@ -95,7 +94,7 @@ CREATE TABLE archive (
bare_peer text NOT NULL,
xml text NOT NULL,
txt text,
id BIGSERIAL,
id BIGSERIAL PRIMARY KEY,
kind text,
nick text,
created_at TIMESTAMP NOT NULL DEFAULT now()
Expand Down Expand Up @@ -174,7 +173,7 @@ CREATE TABLE privacy_list (
CREATE UNIQUE INDEX i_privacy_list_username_name ON privacy_list USING btree (username, name);

CREATE TABLE privacy_list_data (
id bigint REFERENCES privacy_list(id) ON DELETE CASCADE,
id bigint PRIMARY KEY REFERENCES privacy_list(id) ON DELETE CASCADE,
t character(1) NOT NULL,
value text NOT NULL,
action character(1) NOT NULL,
Expand All @@ -186,8 +185,6 @@ CREATE TABLE privacy_list_data (
match_presence_out boolean NOT NULL
);

CREATE INDEX i_privacy_list_data_id ON privacy_list_data USING btree (id);

CREATE TABLE private_storage (
username text NOT NULL,
namespace text NOT NULL,
Expand Down Expand Up @@ -228,15 +225,14 @@ CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node);
CREATE TABLE pubsub_node_option (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
name text NOT NULL,
val text NOT NULL
val text NOT NULL,
PRIMARY KEY (nodeid, name)
);
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option USING btree (nodeid);

CREATE TABLE pubsub_node_owner (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
nodeid bigint PRIMARY KEY REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
owner text NOT NULL
);
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner USING btree (nodeid);

CREATE TABLE pubsub_state (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
Expand Down Expand Up @@ -329,11 +325,10 @@ CREATE TABLE caps_features (
node text NOT NULL,
subnode text NOT NULL,
feature text,
created_at TIMESTAMP NOT NULL DEFAULT now()
created_at TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (node, subnode, feature)
);

CREATE INDEX i_caps_features_node_subnode ON caps_features USING btree (node, subnode);

CREATE TABLE sm (
usec bigint NOT NULL,
pid text NOT NULL,
Expand Down

0 comments on commit f1bf58d

Please sign in to comment.