On Thursday, September 09, 2004 12:49 PM
Peter Gervai <[EMAIL PROTECTED]> wrote:
> A misconfigured GenericAgent created 130000 notes in the tickets. (One
> note every closed ticket every 10 minutes :-). Stupid me.) As I see
> these are in "article" table. Since there are no foreign keys defined
> I cannot really tell whether it's okay to delete these notes or they
> are referenced from other tables. Can I simply delete them from the
> table? (Manually using SQL I mean, like
> DELETE FROM article WHERE a_from='GenericAgent' AND a_subject='stupid
> admin')

No. You have to take care of the references in article_plain,
article_attachement, time_accounting, ticket_history, too, if present.

Most probably you'll have one entry in article_plain and ticket_history,
zero or more in article_attachement and zero or one in time_accounting,
all per article. Well, see this matrix of IDs:

SELECT
    a.id a, ap.id ap, aa.id aa, ta.id ta, th.id th
FROM
    article a
LEFT JOIN article_plain ap
    ON  a.id = ap.article_id
LEFT JOIN article_attachment aa
    ON  a.id = aa.article_id
LEFT JOIN time_accounting ta
    ON  a.id = ta.article_id
LEFT JOIN ticket_history th
    ON  a.id = th.article_id
WHERE
    a.a_from = 'GenericAgent'
AND
    a.a_subject = 'stupid admin'
ORDER BY
    a, ap, aa, ta, th
;

hth,

Robert Kehl

-- 
Für mich gibt es nur "Entweder-Oder". Also entweder voll oder ganz!
Toni Polster

_______________________________________________
OTRS mailing list: otrs - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs
Support oder Consulting für Ihr OTRS System?
=> http://www.otrs.de/

Reply via email to