Uploaded image for project: 'Hybrid Cloud Console'
  1. Hybrid Cloud Console
  2. RHCLOUD-41221

Remove Incident Owner Reminder

XMLWordPrintable

    • Product / Portfolio Work
    • False
    • Hide

      None

      Show
      None
    • False
    • None
    • Unset
    • None

      Since Incident Owner is a required field, the reminder is no longer needed. This task also include the creation of restriction of IncidentOwner required in database. The Incident Owner reminder should be removed and the tests related as well

      IncidentOwner DB restriction:

      func addIncidentOwnerRequired() *gormigrate.Migration {
          return &gormigrate.Migration{
              ID: "202507141300",
              Migrate: func(tx *gorm.DB) error {
                  // Create the function
                  if err := tx.Exec(`
                      CREATE OR REPLACE FUNCTION check_incident_owner()
                      RETURNS TRIGGER AS $$
                      DECLARE
                          owner_count integer;
                      BEGIN
                          SELECT COUNT(*) INTO owner_count
                          FROM incident_participants
                          WHERE incident_id = COALESCE(NEW.incident_id, OLD.incident_id)
                            AND role = 'incident_owner';                    IF owner_count <> 1 THEN
                              RAISE EXCEPTION 'Incident % must have exactly one incident_owner', COALESCE(NEW.incident_id, OLD.incident_id);
                          END IF;
                          RETURN NEW;
                      END;
                      $$ LANGUAGE plpgsql;
                  `).Error; err != nil {
                      return err
                  }            // Create the trigger
                  if err := tx.Exec(`
                      CREATE TRIGGER incident_owner_check
                      AFTER INSERT OR UPDATE OR DELETE ON incident_participants
                      FOR EACH ROW
                      EXECUTE FUNCTION check_incident_owner();
                  `).Error; err != nil {
                      return err
                  }            return nil
              },
              Rollback: func(tx *gorm.DB) error {
                  // Drop the trigger
                  if err := tx.Exec(`DROP TRIGGER IF EXISTS incident_owner_check ON incident_participants;`).Error; err != nil {
                      return err
                  }
                  // Drop the function
                  if err := tx.Exec(`DROP FUNCTION IF EXISTS check_incident_owner();`).Error; err != nil {
                      return err
                  }
                  return nil
              },
          }
      } 

              Unassigned Unassigned
              rh-ee-jbarea Juan Manuel Barea Martinez
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: