Skip to content

Commit b997f95

Browse files
Add column external_uuid to contact/contactgroup table
1 parent 2b3ca42 commit b997f95

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

schema/pgsql/schema.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ CREATE TABLE contact (
5555
username text, -- reference to web user
5656
default_channel_id bigint NOT NULL REFERENCES channel(id),
5757
color varchar(7) NOT NULL, -- hex color codes e.g #000000
58+
external_uuid uuid NOT NULL,
5859

5960
CONSTRAINT pk_contact PRIMARY KEY (id),
6061
UNIQUE (username)
@@ -74,6 +75,7 @@ CREATE TABLE contactgroup (
7475
id bigserial,
7576
name text NOT NULL,
7677
color varchar(7) NOT NULL, -- hex color codes e.g #000000
78+
external_uuid uuid NOT NULL,
7779

7880
CONSTRAINT pk_contactgroup PRIMARY KEY (id)
7981
);

schema/pgsql/upgrades/027.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
2+
3+
ALTER TABLE contact ADD COLUMN external_uuid uuid;
4+
ALTER TABLE contactgroup ADD COLUMN external_uuid uuid;
5+
6+
UPDATE contact SET external_uuid = uuid_generate_v4() WHERE external_uuid IS NULL;
7+
UPDATE contactgroup SET external_uuid = uuid_generate_v4() WHERE external_uuid IS NULL;
8+
9+
ALTER TABLE contact ALTER COLUMN external_uuid SET NOT NULL;
10+
ALTER TABLE contactgroup ALTER COLUMN external_uuid SET NOT NULL;
11+
12+
DROP EXTENSION "uuid-ossp";

0 commit comments

Comments
 (0)