Archive ticket using update sql statement

English! place to talk about development, programming and coding
Post Reply
sunil2012
Znuny newbie
Posts: 23
Joined: 04 Jan 2013, 12:05
Znuny Version: 3.0.10

Archive ticket using update sql statement

Post by sunil2012 »

Hello Team,

I want to archive old tickets, but when doing this from the generic agent job, the ticket is modified for the change_time, change_by and archive_flag columns. Can I do this job using simple sql update statement i.e. ?
update ticket set archive_flag=1 where date(create_time)>='2012-01-01' and date(create_time)<='2012-12-31' and ticket_state_id=2; Would it affect anything else??

Thanks in Advance.
juanman80
Znuny newbie
Posts: 44
Joined: 11 Nov 2011, 10:30
Znuny Version: 5.0.15

Re: Archive ticket using update sql statement

Post by juanman80 »

Are you sure you want to archive all tickets created in 2012? maybe some of them are still opened... We use a generic agent that archives all tickets after 3 months of being closed...
OTRS 5.0.15 on CentOSLinux with MariaDB database connected to an Active Directory for Agents and Customers.
sunil2012
Znuny newbie
Posts: 23
Joined: 04 Jan 2013, 12:05
Znuny Version: 3.0.10

Re: Archive ticket using update sql statement

Post by sunil2012 »

Yes I know, that is why I am using condition for the closed status i.e. ticket_state_id=2. Means I am doing archive those tickets which are closed. Using generic agent job, ticket is update for the change_by and change_time column also but I don't want to change these fields. Secondly at one attempt generic agent archived only around 4000 tickets it means if I have to made for 300000 complaints, then it will be time consuming.
juanman80
Znuny newbie
Posts: 44
Joined: 11 Nov 2011, 10:30
Znuny Version: 5.0.15

Re: Archive ticket using update sql statement

Post by juanman80 »

oh, yes, that happened to me too! I did a script that called the generic agent for a whole night.
with that SQL statement, you would archive tickets created in 2012 but closed yesterday. If you don't allow reopening (follow up) of closed tickets, that's OK.
set_archive_flag sets archive_flag = 1, updates change time and history ticket and throws TicketArchiveFlagUpdate event. If you don't want the updates, maybe you should just comment those lines in ticket.pm, make your changes and then uncomment them
OTRS 5.0.15 on CentOSLinux with MariaDB database connected to an Active Directory for Agents and Customers.
Post Reply