View Ticket
Not logged in
Ticket Hash: d0e0bc0da5dc63187fc64643ff1ce391a02e6237
Title: add ticket created time
Status: Open Type: Feature_Request
Severity: Minor Priority:
Subsystem: Resolution: Works_As_Designed
Last Modified: 2009-12-31 21:15:45
Version Found In:
Description:
ticket schema has tkt_mtime but there is no column which saves the creation time. this would be useful for ordering tickets by open time or by time since last edited. this might be possible using the current ticket configuration but I think it is more appropriate to have a tkt_ctime column that is managed automatically.

<hr><i>anonymous claiming to be Kees Nuyt added on 2008-11-27 23:09:31:</i><br>
Initially I agreed, but considering that tickets are stored with full history (*), and there is a history button, there is no real need for a tkt_ctime column. If you really want one: you can change the ticket table to your liking in Setup, and use any columns in ticket reports.

(*) I seem to have read the current status is obtained by replaying all ticket updates in chronological order, where the newer value replaces an old one, and comments are appended to form the text blocks at the bottom of the ticket detail page.

<hr><i>jeremy_c added on 2009-12-31 03:57:22:</i><br>
I believe you can simply add a column to your ticket schema:

<verbatim>
create_date datetime default CURRENT_TIMESTAMP
</verbatim>


<hr><i>jeremy_c added on 2009-12-31 04:26:49:</i><br>
Yes, the code above works just fine.

<hr><i>rwilson added on 2009-12-31 19:42:25:</i><br>
actually, i just tested the schema changes solution above; editing a ticket updates the created time.  this is because, essentially, editing a ticket performs a DELETE then an INSERT, so the default CURRENT_DATETIME gets evaluated fresh again.  (i confirmed this by inspecting tkt.c [98960a5cdc].)

i'm not sure that the OP's request can be resolved without writing some fossil code.  i'm going to try a few more things with the ui to see if i can get the desired result, but i don't have any more time today.

<hr><i>jeremy_c added on 2009-12-31 21:15:45:</i><br>
You are right. I wanted to implement this in my own repo, so I added some code and tested. This method works :-)

Add to your database schema something like:

<verbatim>
create_date TEXT
</verbatim>

Then in your New Ticket template, add something like:

<verbatim>
<th1>
  if {[info exists submit]} {
     set create_date [date]
     submit_ticket
  }
</th1>
</verbatim>

You likely already have the above if statement and only need to add the <tt>set create_date</tt> part. You can then display the create date in your View template.

Sorry for the bum fix to start with. I made a simple test case and didn't test editing.