diff --git a/pkg/database/models.go b/pkg/database/models.go index d40c03c..bd113fb 100644 --- a/pkg/database/models.go +++ b/pkg/database/models.go @@ -98,12 +98,12 @@ type Talkgroup struct { } type TalkgroupsLearned struct { - ID int32 `json:"id"` - SystemID int `json:"system_id"` - TGID int `json:"tgid"` - Name string `json:"name"` - AlphaTag *string `json:"alpha_tag"` - Ignored *bool `json:"ignored"` + ID uuid.UUID `json:"id"` + SystemID int `json:"system_id"` + TGID int `json:"tgid"` + Name string `json:"name"` + AlphaTag *string `json:"alpha_tag"` + Ignored *bool `json:"ignored"` } type User struct { diff --git a/pkg/database/talkgroups.go b/pkg/database/talkgroups.go index 40d3b2b..276b0d8 100644 --- a/pkg/database/talkgroups.go +++ b/pkg/database/talkgroups.go @@ -34,7 +34,7 @@ JOIN systems sys ON tg.system_id = sys.id JOIN UNNEST($1::INT4[], $2::INT4[]) AS tgt(sys, tg) ON (tg.system_id = tgt.sys AND tg.tgid = tgt.tg) UNION SELECT -NULL::UUID, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, +tgl.id, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, tgl.alpha_tag, tgl.alpha_tag, NULL::INTEGER, NULL::JSONB, CASE WHEN tgl.alpha_tag IS NULL THEN NULL ELSE ARRAY[tgl.alpha_tag] END, TRUE, NULL::JSONB, 1.0, sys.id, sys.name, diff --git a/pkg/database/talkgroups.sql.go b/pkg/database/talkgroups.sql.go index 46e8939..a369ff2 100644 --- a/pkg/database/talkgroups.sql.go +++ b/pkg/database/talkgroups.sql.go @@ -106,7 +106,7 @@ JOIN systems sys ON tg.system_id = sys.id WHERE (tg.system_id, tg.tgid) = ($1, $2) UNION SELECT -NULL::UUID, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, +tgl.id, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, tgl.alpha_tag, tgl.alpha_tag, NULL::INTEGER, NULL::JSONB, CASE WHEN tgl.alpha_tag IS NULL THEN NULL ELSE ARRAY[tgl.alpha_tag] END, TRUE, NULL::JSONB, 1.0, sys.id, sys.name, @@ -237,7 +237,7 @@ FROM talkgroups tg JOIN systems sys ON tg.system_id = sys.id UNION SELECT -NULL::UUID, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, +tgl.id, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, tgl.alpha_tag, tgl.alpha_tag, NULL::INTEGER, NULL::JSONB, CASE WHEN tgl.alpha_tag IS NULL THEN NULL ELSE ARRAY[tgl.alpha_tag] END, TRUE, NULL::JSONB, 1.0, sys.id, sys.name, @@ -298,7 +298,7 @@ JOIN systems sys ON tg.system_id = sys.id WHERE tg.system_id = $1 UNION SELECT -NULL::UUID, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, +tgl.id, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, tgl.alpha_tag, tgl.alpha_tag, NULL::INTEGER, NULL::JSONB, CASE WHEN tgl.alpha_tag IS NULL THEN NULL ELSE ARRAY[tgl.alpha_tag] END, TRUE, NULL::JSONB, 1.0, sys.id, sys.name, diff --git a/sql/postgres/migrations/001_initial.up.sql b/sql/postgres/migrations/001_initial.up.sql index f412f28..cd37bc9 100644 --- a/sql/postgres/migrations/001_initial.up.sql +++ b/sql/postgres/migrations/001_initial.up.sql @@ -44,7 +44,7 @@ CREATE INDEX talkgroups_system_tgid_idx ON talkgroups (system_id, tgid); CREATE INDEX IF NOT EXISTS talkgroup_id_tags ON talkgroups USING GIN (tags); CREATE TABLE IF NOT EXISTS talkgroups_learned( - id SERIAL PRIMARY KEY, + id UUID PRIMARY KEY, system_id INTEGER REFERENCES systems(id) NOT NULL, tgid INTEGER NOT NULL, name TEXT NOT NULL, diff --git a/sql/postgres/queries/talkgroups.sql b/sql/postgres/queries/talkgroups.sql index 7ad3e53..6b58ae8 100644 --- a/sql/postgres/queries/talkgroups.sql +++ b/sql/postgres/queries/talkgroups.sql @@ -33,7 +33,7 @@ JOIN systems sys ON tg.system_id = sys.id WHERE (tg.system_id, tg.tgid) = (@system_id, @tgid) UNION SELECT -NULL::UUID, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, +tgl.id, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, tgl.alpha_tag, tgl.alpha_tag, NULL::INTEGER, NULL::JSONB, CASE WHEN tgl.alpha_tag IS NULL THEN NULL ELSE ARRAY[tgl.alpha_tag] END, TRUE, NULL::JSONB, 1.0, sys.id, sys.name, @@ -51,7 +51,7 @@ JOIN systems sys ON tg.system_id = sys.id WHERE tg.system_id = @system UNION SELECT -NULL::UUID, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, +tgl.id, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, tgl.alpha_tag, tgl.alpha_tag, NULL::INTEGER, NULL::JSONB, CASE WHEN tgl.alpha_tag IS NULL THEN NULL ELSE ARRAY[tgl.alpha_tag] END, TRUE, NULL::JSONB, 1.0, sys.id, sys.name, @@ -68,7 +68,7 @@ FROM talkgroups tg JOIN systems sys ON tg.system_id = sys.id UNION SELECT -NULL::UUID, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, +tgl.id, tgl.system_id::INT4, tgl.tgid::INT4, tgl.name, tgl.alpha_tag, tgl.alpha_tag, NULL::INTEGER, NULL::JSONB, CASE WHEN tgl.alpha_tag IS NULL THEN NULL ELSE ARRAY[tgl.alpha_tag] END, TRUE, NULL::JSONB, 1.0, sys.id, sys.name,