| 109 | === Updating the database === |
| 110 | |
| 111 | As noted above, any tickets created before a custom field has been defined will not have a value for that field. Here's a bit of SQL (tested with SQLite) that you can run directly on the Trac database to set an initial value for custom tickt fields. Inserts the default value of 'None' into a custom field called 'request_source' for all tickets that have no existing value: |
| 112 | |
| 113 | {{{ |
| 114 | #!sql |
| 115 | INSERT INTO ticket_custom |
| 116 | (ticket, name, value) |
| 117 | SELECT |
| 118 | id AS ticket, |
| 119 | 'request_source' AS name, |
| 120 | 'None' AS value |
| 121 | FROM ticket |
| 122 | WHERE id NOT IN ( |
| 123 | SELECT ticket FROM ticket_custom |
| 124 | ); |
| 125 | }}} |
| 126 | |