39
|
1 from trac.db import Table, Column, Index, DatabaseManager
|
|
2
|
|
3 def do_upgrade(env, ver, cursor):
|
|
4 """Rename the column `sql` in the `report` table for compatibity with MySQL.
|
|
5 """
|
|
6 cursor.execute("CREATE TEMPORARY TABLE report_old AS SELECT * FROM report")
|
|
7 cursor.execute("DROP TABLE report")
|
|
8
|
|
9 table = Table('report', key='id')[
|
|
10 Column('id', auto_increment=True),
|
|
11 Column('author'),
|
|
12 Column('title'),
|
|
13 Column('query'),
|
|
14 Column('description')
|
|
15 ]
|
|
16 db_connector, _ = DatabaseManager(env)._get_connector()
|
|
17 for stmt in db_connector.to_sql(table):
|
|
18 cursor.execute(stmt)
|
|
19
|
|
20 cursor.execute("INSERT INTO report (id,author,title,query,description) "
|
|
21 "SELECT id,author,title,sql,description FROM report_old")
|
|
22 cursor.execute("DROP TABLE report_old")
|