show/hide this revision's text 3 Remove unnecessary word

A warning about modifying the database directly...

I had to do delete a cross-reference yesterday (I added an incorrect cross-reference to a case which had the potential to cause huge confusion). After I deleted the bad entry from the bugrelation table, I also deleted the corresponding event from the bugevent table. Unfortunately, this had been the last bugevent for the bug, and so FogBugz couldn't find the event corresponding to the ixBugEventLatest field in the bug table and refused to display it in any filters...

I used this to look for other instances where I might have inadvertently deleted the last bugevent for a bug:

SELECT b.ixBug,MAX(ixBugEvent),b.ixBugEventLatest
  FROM bug b
  JOIN bugevent e
    ON b.ixBug = e.ixBug
 WHERE (SELECT MAX(x.ixBugEvent)
          FROM bugEvent x
         WHERE x.ixBug=e.ixBug) <> b.ixBugEventLatest
GROUP BY e.ixBug;
show/hide this revision's text 2 pretty linebreaks

A warning about modifying the database directly...

I had to do delete a cross-reference yesterday (I added an incorrect cross-reference to a case which had the potential to cause huge confusion). After I deleted the bad entry from the bugrelation table, I also deleted the corresponding event from the bugevent table. Unfortunately, this had been the last bugevent for the bug, and so FogBugz couldn't find the event corresponding to the ixBugEventLatest field in the bug table and refused to display it in any filters...

I used this to look for other instances where I might have inadvertently deleted the last bugevent for a bug:

SELECT b.ixBug,MAX(ixBugEvent),b.ixBugEventLatest
  FROM bug b
  JOIN bugevent e
    ON b.ixBug = e.ixBug
 WHERE (SELECT MAX(x.ixBugEvent)
          FROM bugEvent x
         WHERE x.ixBug=e.ixBug) <>b.ixBugEventLatest <> b.ixBugEventLatest
GROUP BY e.ixBug;
show/hide this revision's text 1

A warning about modifying the database directly...

I had to do delete a cross-reference yesterday (I added an incorrect cross-reference to a case which had the potential to cause huge confusion). After I deleted the bad entry from the bugrelation table, I also deleted the corresponding event from the bugevent table. Unfortunately, this had been the last bugevent for the bug, and so FogBugz couldn't find the event corresponding to the ixBugEventLatest field in the bug table and refused to display it in any filters...

I used this to look for other instances where I might have inadvertently deleted the last bugevent for a bug:

SELECT b.ixBug,MAX(ixBugEvent),b.ixBugEventLatest FROM bug b JOIN bugevent e ON b.ixBug = e.ixBug WHERE (SELECT MAX(x.ixBugEvent) FROM bugEvent x WHERE x.ixBug=e.ixBug)<>b.ixBugEventLatest GROUP BY e.ixBug;