[rt-users] Inserting tickets directly to database

Peter Silver psilver at ultrafast.com.au
Tue Jun 29 21:46:15 EDT 2004


On Wed, 2004-06-30 at 11:02, Cerion Armour-Brown wrote:
> On Wednesday 30 June 2004 01:37, Peter Silver wrote:
>
> > The only lost info might be the creation date of each ticket, though you
> > could easily loop through each ticket again and correct the Created date
> > of each transaction associated with the ticket.
>
> Good point, didn't think of this - Would you do this via the cli, or would you 
> use the RT api, and maybe take advantage of 'RecordTransaction=0'...?

If I were doing this as a once-off type thing, I'd write a script that
accesses the DB directly (because I haven't played with the RT API). 
The script would need to do the following;

1.  Grab the TicketId & create date of the ticket from the original data
    source.

2.  Perform a query on the Attachments table for something like;
      select TransactionId from Attachments where (Headers like
      '%\nX-Orig-TicketId: <Orig TicketId>\n%');

    (this could be a bit slow on a large RT db)

3.  Use the TransactionId to get the new TicketId;
      select Ticket from Transactions where (id = <Transaction Id>);

4.  Update the Created date of the transactions;
      update Transactions set Created=<Orig Created> where
      (Ticket = 'New TicketId');

Someone with RT API experience could probably come up with a safer
method for achieving this, assuming the API lets you modify the create
date of transactions associated with a ticket.


Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20040630/73d6d14f/attachment.sig>


More information about the rt-users mailing list