@@ -47,7 +47,9 @@ CREATE TABLE channel (
4747    config text , --  JSON with channel-specific attributes
4848    --  for now type determines the implementation, in the future, this will need a reference to a concrete
4949    --  implementation to allow multiple implementations of a sms channel for example, probably even user-provided ones
50+     external_uuid uuid NOT NULL ,
5051
52+     UNIQUE (external_uuid),
5153    CONSTRAINT  pk_channel PRIMARY KEY  (id)
5254);
5355
@@ -56,9 +58,11 @@ CREATE TABLE contact (
5658    full_name citext NOT NULL ,
5759    username citext, --  reference to web user
5860    default_channel_id bigint  NOT NULL  REFERENCES  channel(id),
61+     external_uuid uuid NOT NULL ,
5962
60-     CONSTRAINT  pk_contact PRIMARY KEY  (id),
61-     UNIQUE (username)
63+     UNIQUE (username),
64+     UNIQUE (external_uuid),
65+     CONSTRAINT  pk_contact PRIMARY KEY  (id)
6266);
6367
6468CREATE  TABLE  contact_address  (
@@ -74,7 +78,9 @@ CREATE TABLE contact_address (
7478CREATE  TABLE  contactgroup  (
7579    id bigserial ,
7680    name citext NOT NULL ,
81+     external_uuid uuid NOT NULL ,
7782
83+     UNIQUE (external_uuid),
7884    CONSTRAINT  pk_contactgroup PRIMARY KEY  (id)
7985);
8086
0 commit comments