Skip to content

Commit

Permalink
Change PostgreSQL SERIAL to BIGSERIAL columns
Browse files Browse the repository at this point in the history
This is consistent with other schemas, internally consistent with
foreign keys, and allows for > 2B records in these tables.
  • Loading branch information
nosnilmot committed Jan 19, 2023
1 parent d5bf051 commit 4f0e426
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions sql/pg.new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ CREATE TABLE spool (
username text NOT NULL,
server_host text NOT NULL,
xml text NOT NULL,
seq SERIAL,
seq BIGSERIAL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);

Expand All @@ -258,7 +258,7 @@ CREATE TABLE archive (
bare_peer text NOT NULL,
xml text NOT NULL,
txt text,
id SERIAL,
id BIGSERIAL,
kind text,
nick text,
created_at TIMESTAMP NOT NULL DEFAULT now()
Expand Down Expand Up @@ -339,7 +339,7 @@ CREATE TABLE privacy_list (
username text NOT NULL,
server_host text NOT NULL,
name text NOT NULL,
id SERIAL UNIQUE,
id BIGSERIAL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT now()
);

Expand Down Expand Up @@ -394,7 +394,7 @@ CREATE TABLE pubsub_node (
node text NOT NULL,
parent text NOT NULL DEFAULT '',
plugin text NOT NULL,
nodeid SERIAL UNIQUE
nodeid BIGSERIAL UNIQUE
);
CREATE INDEX i_pubsub_node_parent ON pubsub_node USING btree (parent);
CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node);
Expand All @@ -417,7 +417,7 @@ CREATE TABLE pubsub_state (
jid text NOT NULL,
affiliation character(1),
subscriptions text NOT NULL DEFAULT '',
stateid SERIAL UNIQUE
stateid BIGSERIAL UNIQUE
);
CREATE INDEX i_pubsub_state_jid ON pubsub_state USING btree (jid);
CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state USING btree (nodeid, jid);
Expand Down
10 changes: 5 additions & 5 deletions sql/pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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 SERIAL,
seq BIGSERIAL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);

Expand All @@ -95,7 +95,7 @@ CREATE TABLE archive (
bare_peer text NOT NULL,
xml text NOT NULL,
txt text,
id SERIAL,
id BIGSERIAL,
kind text,
nick text,
created_at TIMESTAMP NOT NULL DEFAULT now()
Expand Down Expand Up @@ -167,7 +167,7 @@ CREATE TABLE privacy_default_list (
CREATE TABLE privacy_list (
username text NOT NULL,
name text NOT NULL,
id SERIAL UNIQUE,
id BIGSERIAL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT now()
);

Expand Down Expand Up @@ -220,7 +220,7 @@ CREATE TABLE pubsub_node (
node text NOT NULL,
parent text NOT NULL DEFAULT '',
plugin text NOT NULL,
nodeid SERIAL UNIQUE
nodeid BIGSERIAL UNIQUE
);
CREATE INDEX i_pubsub_node_parent ON pubsub_node USING btree (parent);
CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node);
Expand All @@ -243,7 +243,7 @@ CREATE TABLE pubsub_state (
jid text NOT NULL,
affiliation character(1),
subscriptions text NOT NULL DEFAULT '',
stateid SERIAL UNIQUE
stateid BIGSERIAL UNIQUE
);
CREATE INDEX i_pubsub_state_jid ON pubsub_state USING btree (jid);
CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state USING btree (nodeid, jid);
Expand Down

0 comments on commit 4f0e426

Please sign in to comment.