Deleting tickets: How to find the "database ID"?

For some debugging we had to create 50+ test tickets, which we really would like to completely delete from Zammad, statistics ecc. ecc. Deleting Records — Zammad documentation mentions, that tickets can be deleted with the following commands in the Rails console:

Ticket.find($database_id).destroy

But: How can I find the “database ID” of a specific ticket?

It’s the ticket ID. You can search your tickets by attributes. If you type something like this in the rails console, then you should get the ticket information of that particular ticket.

Ticket.find_by(“title”:“Title of your ticket”)

On the terminal you should get something like this:

irb(main):001:0> Ticket.find_by(“title”:“xyz”)
=> #<Ticket id: 310,

In this instance 310 would be the value that I would insert in your command.

1 Like

Hey @fthommen ,

you can actually also see the ID in the webinterface.

Edit:
If you want to use the number instead you can do:

DANGER ZONE

:skull_and_crossbones: The commands listed here cause irrecoverable data loss! Only proceed if you know what you’re doing and you have a backup!

I totally read and understood the information above, i promise!

Ticket.find_by(number:$ticket_number).destroy

cheers

1 Like

@dvnkln please make your answer fool proof and put it into clear spoiler warning tags.
For the own safety of our precious copy cats that don’t understand the scope.

1 Like

Thank for your very helpful answers @PurpleShirt and @dvnkln. Both solve my problem, but unfortunately I can only set one post as solution :frowning: . We are already successfully deleting obsolete test tickets, using a combined approach :slight_smile:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.