Skip to content

Commit

Permalink
Merge pull request #767 from Icinga/icingadb-migrate-null-name-i766
Browse files Browse the repository at this point in the history
icingadb-migrate: Mitigate NULL names in {comment,downtime}_query
  • Loading branch information
julianbrost authored Jul 31, 2024
2 parents 56d83da + 59685cd commit 9946fa5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmd/icingadb-migrate/embed/comment_query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ SELECT ch.commenthistory_id, UNIX_TIMESTAMP(ch.entry_time) entry_time,
ch.entry_time_usec, ch.entry_type, ch.author_name, ch.comment_data, ch.is_persistent,
COALESCE(UNIX_TIMESTAMP(ch.expiration_time), 0) expiration_time,
COALESCE(UNIX_TIMESTAMP(ch.deletion_time), 0) deletion_time,
ch.deletion_time_usec, ch.name, o.objecttype_id, o.name1, COALESCE(o.name2, '') name2
ch.deletion_time_usec,
COALESCE(ch.name, CONCAT(o.name1, '!', COALESCE(o.name2, ''), '!', ch.commenthistory_id, '-', ch.object_id)) name,
o.objecttype_id, o.name1, COALESCE(o.name2, '') name2
FROM icinga_commenthistory ch USE INDEX (PRIMARY)
INNER JOIN icinga_objects o ON o.object_id=ch.object_id
WHERE ch.commenthistory_id BETWEEN :fromid AND :toid
Expand Down
5 changes: 3 additions & 2 deletions cmd/icingadb-migrate/embed/downtime_query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ SELECT dh.downtimehistory_id, UNIX_TIMESTAMP(dh.entry_time) entry_time, dh.autho
COALESCE(UNIX_TIMESTAMP(dh.scheduled_end_time), 0) scheduled_end_time, dh.was_started,
COALESCE(UNIX_TIMESTAMP(dh.actual_start_time), 0) actual_start_time, dh.actual_start_time_usec,
COALESCE(UNIX_TIMESTAMP(dh.actual_end_time), 0) actual_end_time, dh.actual_end_time_usec, dh.was_cancelled,
COALESCE(UNIX_TIMESTAMP(dh.trigger_time), 0) trigger_time, dh.name, o.objecttype_id,
o.name1, COALESCE(o.name2, '') name2, COALESCE(sd.name, '') triggered_by
COALESCE(UNIX_TIMESTAMP(dh.trigger_time), 0) trigger_time,
COALESCE(dh.name, CONCAT(o.name1, '!', COALESCE(o.name2, ''), '!', dh.downtimehistory_id, '-', dh.object_id)) name,
o.objecttype_id, o.name1, COALESCE(o.name2, '') name2, COALESCE(sd.name, '') triggered_by
FROM icinga_downtimehistory dh USE INDEX (PRIMARY)
INNER JOIN icinga_objects o ON o.object_id=dh.object_id
LEFT JOIN icinga_scheduleddowntime sd ON sd.scheduleddowntime_id=dh.triggered_by_id
Expand Down

0 comments on commit 9946fa5

Please sign in to comment.