Mercurial > genshi > mirror
comparison examples/trac/trac/upgrades/db17.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 from trac.db import Table, Column, Index, DatabaseManager | |
2 | |
3 def do_upgrade(env, ver, cursor): | |
4 """Rename the columns `kind` and `change` in the `node_change` table for | |
5 compatibity with MySQL. | |
6 """ | |
7 cursor.execute("CREATE TEMPORARY TABLE nc_old AS SELECT * FROM node_change") | |
8 cursor.execute("DROP TABLE node_change") | |
9 | |
10 table = Table('node_change', key=('rev', 'path', 'change_type'))[ | |
11 Column('rev'), | |
12 Column('path'), | |
13 Column('node_type', size=1), | |
14 Column('change_type', size=1), | |
15 Column('base_path'), | |
16 Column('base_rev'), | |
17 Index(['rev']) | |
18 ] | |
19 db_connector, _ = DatabaseManager(env)._get_connector() | |
20 for stmt in db_connector.to_sql(table): | |
21 cursor.execute(stmt) | |
22 | |
23 cursor.execute("INSERT INTO node_change (rev,path,node_type,change_type," | |
24 "base_path,base_rev) SELECT rev,path,kind,change," | |
25 "base_path,base_rev FROM nc_old") | |
26 cursor.execute("DROP TABLE nc_old") |