Fix primary key

This commit is contained in:
Daniel 2024-07-17 19:51:29 -04:00
parent e9dbfe33e3
commit 30a1965094
2 changed files with 4 additions and 4 deletions

View file

@ -63,7 +63,7 @@ type System struct {
} }
type Talkgroup struct { type Talkgroup struct {
System int32 SystemID int32
Tgid int32 Tgid int32
Name pgtype.Text Name pgtype.Text
Frequency pgtype.Int4 Frequency pgtype.Int4

View file

@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS systems(
); );
CREATE TABLE IF NOT EXISTS talkgroups( CREATE TABLE IF NOT EXISTS talkgroups(
system INTEGER REFERENCES systems(id) NOT NULL, system_id INTEGER REFERENCES systems(id) NOT NULL,
tgid INTEGER, tgid INTEGER,
name TEXT, name TEXT,
frequency INTEGER, frequency INTEGER,
@ -39,9 +39,9 @@ CREATE TABLE IF NOT EXISTS talkgroups_tags(
system_id INTEGER NOT NULL, system_id INTEGER NOT NULL,
talkgroup_id INTEGER NOT NULL, talkgroup_id INTEGER NOT NULL,
tags TEXT[] NOT NULL DEFAULT '{}', tags TEXT[] NOT NULL DEFAULT '{}',
FOREIGN KEY (system_id, talkgroup_id) REFERENCES talkgroups (system, tgid) FOREIGN KEY (system_id, talkgroup_id) REFERENCES talkgroups (system_id, tgid),
PRIMARY KEY (system_id, talkgroup_id)
); );
CREATE UNIQUE INDEX IF NOT EXISTS talkgroups_tags_id_talkgroup_id ON talkgroups_tags(system_id, talkgroup_id);
CREATE INDEX IF NOT EXISTS talkgroup_tags_id_tags ON talkgroups_tags USING GIN (tags); CREATE INDEX IF NOT EXISTS talkgroup_tags_id_tags ON talkgroups_tags USING GIN (tags);
CREATE TABLE IF NOT EXISTS calls( CREATE TABLE IF NOT EXISTS calls(