File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -55,9 +55,11 @@ CREATE TABLE contact (
5555 username citext, -- 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),
60- UNIQUE (username)
61+ UNIQUE (username),
62+ UNIQUE (external_uuid)
6163);
6264
6365CREATE TABLE contact_address (
@@ -74,8 +76,10 @@ CREATE TABLE contactgroup (
7476 id bigserial ,
7577 name citext NOT NULL ,
7678 color varchar (7 ) NOT NULL , -- hex color codes e.g #000000
79+ external_uuid uuid NOT NULL ,
7780
78- CONSTRAINT pk_contactgroup PRIMARY KEY (id)
81+ CONSTRAINT pk_contactgroup PRIMARY KEY (id),
82+ UNIQUE (external_uuid)
7983);
8084
8185CREATE TABLE contactgroup_member (
Original file line number Diff line number Diff line change 1+ CREATE EXTENSION IF NOT EXISTS " uuid-ossp" ;
2+
3+ ALTER TABLE contact ADD COLUMN external_uuid uuid UNIQUE;
4+ ALTER TABLE contactgroup ADD COLUMN external_uuid uuid UNIQUE;
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" ;
13+
14+
15+ ALTER TABLE contact DROP COLUMN external_uuid;
16+ ALTER TABLE contactgroup DROP COLUMN external_uuid;
You can’t perform that action at this time.
0 commit comments