Software Freedom Law Center

root/trunk/trac/contrib/migrateticketmodel.py

Revision 46, 1.2 kB (checked in by bkuhn, 11 months ago)

I am keeping a temporary fork of trac as I work on various changes to
it. I'll be coordinating with their mailing list soon.

Line 
1 #!/usr/bin/env python
2 #
3 # This script completely migrates a <= 0.8.x Trac environment to use the new
4 # default ticket model introduced in Trac 0.9.
5 #
6 # In particular, this means that the severity field is removed (or rather
7 # disabled by removing all possible values), and the priority values are
8 # changed to the more meaningful new defaults.
9 #
10 # Make sure to make a backup of the Trac environment before running this!
11
12 import os
13 import sys
14
15 from trac.env import open_environment
16 from trac.ticket.model import Priority, Severity
17
18 priority_mapping = {
19     'highest':  'blocker',
20     'high':     'critical',
21     'normal':   'major',
22     'low':      'minor',
23     'lowest':   'trivial'
24 }
25
26 def main():
27     if len(sys.argv) < 2:
28         print >> sys.stderr, 'usage: %s /path/to/projenv' \
29                              % os.path.basename(sys.argv[0])
30         sys.exit(2)
31
32     env = open_environment(sys.argv[1])
33     db = env.get_db_cnx()
34
35     for oldprio, newprio in priority_mapping.items():
36         priority = Priority(env, oldprio, db)
37         priority.name = newprio
38         priority.update(db)
39
40     for severity in list(Severity.select(env, db)):
41         severity.delete(db)
42
43     db.commit()
44
45 if __name__ == '__main__':
46     main()
Note: See TracBrowser for help on using the browser.

SFLC Main Page

[frdm] Support SFLC