comparison examples/trac/trac/upgrades/db14.py @ 39:93b4dcbafd7b trunk

Copy Trac to main branch.
author cmlenz
date Mon, 03 Jul 2006 18:53:27 +0000
parents
children
comparison
equal deleted inserted replaced
38:ee669cb9cccc 39:93b4dcbafd7b
1 sql = [
2 """CREATE TEMPORARY TABLE node_change_old AS SELECT * FROM node_change;""",
3 """DROP TABLE node_change;""",
4 """CREATE TABLE node_change (
5 rev text,
6 path text,
7 kind char(1),
8 change char(1),
9 base_path text,
10 base_rev text,
11 UNIQUE(rev, path, change)
12 );""",
13 """INSERT INTO node_change (rev,path,kind,change,base_path,base_rev)
14 SELECT rev,path,kind,change,base_path,base_rev FROM node_change_old;""",
15 """DROP TABLE node_change_old;"""
16 ]
17
18 def do_upgrade(env, ver, cursor):
19 # Wiki pages were accidentially created with the version number starting at
20 # 0 instead of 1; This should fix that
21 cursor.execute("SELECT name, version FROM wiki WHERE name IN "
22 "(SELECT name FROM wiki WHERE version=0) ORDER BY name,"
23 "version DESC")
24 result = cursor.fetchall()
25 if result:
26 cursor.executemany("UPDATE wiki SET version=version+1 WHERE name=%s "
27 "and version=%s",
28 [tuple(row) for row in result])
29
30 # Correct difference between db_default.py and upgrades/db10.py: The
31 # 'change' was missing from the uniqueness constraint
32 for s in sql:
33 cursor.execute(s)
Copyright (C) 2012-2017 Edgewall Software