Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6
github.com/emersion/go-smtp v0.24.0
github.com/google/uuid v1.6.0
github.com/icinga/icinga-go-library v0.9.1-0.20260703073729-01bbc172ffe3
github.com/icinga/icinga-go-library v0.9.1-0.20260714123216-927526041e77
github.com/jhillyerd/enmime v1.3.0
github.com/jmoiron/sqlx v1.4.0
github.com/okzk/sdnotify v0.0.0-20180710141335-d9becc38acbd
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/icinga/icinga-go-library v0.9.1-0.20260703073729-01bbc172ffe3 h1:SQfajIIhA8MSEz4/TvvkoZ3KelZqehN0p5cO+s6V+oY=
github.com/icinga/icinga-go-library v0.9.1-0.20260703073729-01bbc172ffe3/go.mod h1:XFsuZEn2hrE3YXQ3NHqnI2UkjdZgJJWb/7D/+VH6MsE=
github.com/icinga/icinga-go-library v0.9.1-0.20260714123216-927526041e77 h1:YQS63i/R9rHd72SYfNdSDZzgiU4kp1tv3vkdYyf4skM=
github.com/icinga/icinga-go-library v0.9.1-0.20260714123216-927526041e77/go.mod h1:HDw4ODUuK0oineNCDzrJjFBdI0i1F3O2ODbQsiAiZ8k=
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 h1:iCHtR9CQyktQ5+f3dMVZfwD2KWJUgm7M0gdL9NGr8KA=
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
Expand Down
1 change: 1 addition & 0 deletions internal/incident/db_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

// ContactRow represents a single incident contact database entry.
type ContactRow struct {
ID int64 `db:"id"`
IncidentID int64 `db:"incident_id"`
recipient.Key `db:",inline"`
Role ContactRole `db:"role"`
Expand Down
2 changes: 1 addition & 1 deletion internal/incident/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (i *Incident) AddRecipient(ctx context.Context, tx *sqlx.Tx, escalation *ru
cr.Role = state.Role
}

stmt, _ := i.db.BuildUpsertStmt(cr)
stmt, _ := i.db.BuildUpsertStmt(cr, "id")
_, err := tx.NamedExecContext(ctx, stmt, cr)
if err != nil {
i.logger.Errorw(
Expand Down
2 changes: 2 additions & 0 deletions schema/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,15 @@ CREATE TABLE incident (
CREATE INDEX idx_incident_recovered_at ON incident(recovered_at);

CREATE TABLE incident_contact (
id bigint NOT NULL AUTO_INCREMENT, -- not used for anything, but is required to satisfy some Galera cluster constraints not allowing to replicate a table without a PK.
incident_id bigint NOT NULL,
contact_id bigint,
contactgroup_id bigint,
schedule_id bigint,
role enum('recipient', 'subscriber', 'manager'), -- NOT NULL is enforced via CHECK not to default to 'recipient'
changed_at bigint NOT NULL, -- used only by Notifications Web to show when the recipients role was last changed.

CONSTRAINT pk_incident_contact PRIMARY KEY (id),
CONSTRAINT uk_incident_contact_incident_id_contact_id UNIQUE (incident_id, contact_id),
CONSTRAINT uk_incident_contact_incident_id_contactgroup_id UNIQUE (incident_id, contactgroup_id),
CONSTRAINT uk_incident_contact_incident_id_schedule_id UNIQUE (incident_id, schedule_id),
Expand Down
3 changes: 3 additions & 0 deletions schema/mysql/upgrades/incident_contact-pk.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE incident_contact
ADD COLUMN id bigint NOT NULL AUTO_INCREMENT FIRST,
ADD CONSTRAINT pk_incident_contact PRIMARY KEY (id);
3 changes: 3 additions & 0 deletions schema/pgsql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,16 @@ CREATE INDEX idx_incident_recovered_at ON incident(recovered_at);
CREATE TYPE incident_contact_role AS ENUM ('recipient', 'subscriber', 'manager');

CREATE TABLE incident_contact (
id bigserial, -- not used for anything, but is required to satisfy some Galera cluster constraints not allowing to replicate a table without a PK.
incident_id bigint NOT NULL,
contact_id bigint,
contactgroup_id bigint,
schedule_id bigint,
role incident_contact_role NOT NULL,
changed_at bigint NOT NULL, -- used only by Notifications Web to show when the recipients role was last changed.

CONSTRAINT pk_incident_contact PRIMARY KEY (id),

-- Keep in sync with internal/incident/db_types.go!
CONSTRAINT uk_incident_contact_incident_id_contact_id UNIQUE (incident_id, contact_id),
CONSTRAINT uk_incident_contact_incident_id_contactgroup_id UNIQUE (incident_id, contactgroup_id),
Expand Down
3 changes: 3 additions & 0 deletions schema/pgsql/upgrades/incident_contact-pk.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE incident_contact
ADD COLUMN id bigserial,
ADD CONSTRAINT pk_incident_contact PRIMARY KEY (id);
Loading