Skip to content

Commit

Permalink
Add column external_uuid to contact/contactgroup table
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jun 12, 2024
1 parent 2b3ca42 commit b997f95
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions schema/pgsql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ CREATE TABLE contact (
username text, -- reference to web user
default_channel_id bigint NOT NULL REFERENCES channel(id),
color varchar(7) NOT NULL, -- hex color codes e.g #000000
external_uuid uuid NOT NULL,

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

CONSTRAINT pk_contactgroup PRIMARY KEY (id)
);
Expand Down
12 changes: 12 additions & 0 deletions schema/pgsql/upgrades/027.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

ALTER TABLE contact ADD COLUMN external_uuid uuid;
ALTER TABLE contactgroup ADD COLUMN external_uuid uuid;

UPDATE contact SET external_uuid = uuid_generate_v4() WHERE external_uuid IS NULL;
UPDATE contactgroup SET external_uuid = uuid_generate_v4() WHERE external_uuid IS NULL;

ALTER TABLE contact ALTER COLUMN external_uuid SET NOT NULL;
ALTER TABLE contactgroup ALTER COLUMN external_uuid SET NOT NULL;

DROP EXTENSION "uuid-ossp";

0 comments on commit b997f95

Please sign in to comment.