Fix primary key
This commit is contained in:
parent
e9dbfe33e3
commit
30a1965094
2 changed files with 4 additions and 4 deletions
|
@ -63,7 +63,7 @@ type System struct {
|
|||
}
|
||||
|
||||
type Talkgroup struct {
|
||||
System int32
|
||||
SystemID int32
|
||||
Tgid int32
|
||||
Name pgtype.Text
|
||||
Frequency pgtype.Int4
|
||||
|
|
|
@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS systems(
|
|||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS talkgroups(
|
||||
system INTEGER REFERENCES systems(id) NOT NULL,
|
||||
system_id INTEGER REFERENCES systems(id) NOT NULL,
|
||||
tgid INTEGER,
|
||||
name TEXT,
|
||||
frequency INTEGER,
|
||||
|
@ -39,9 +39,9 @@ CREATE TABLE IF NOT EXISTS talkgroups_tags(
|
|||
system_id INTEGER NOT NULL,
|
||||
talkgroup_id INTEGER NOT NULL,
|
||||
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 TABLE IF NOT EXISTS calls(
|
||||
|
|
Loading…
Reference in a new issue