1# -*- coding: utf-8 -*- 2# 3# Copyright (C) 2006-2021 Edgewall Software 4# All rights reserved. 5# 6# This software is licensed as described in the file COPYING, which 7# you should have received as part of this distribution. The terms 8# are also available at https://trac.edgewall.org/wiki/TracLicense. 9# 10# This software consists of voluntary contributions made by many 11# individuals. For the exact contribution history, see the revision 12# history and logs, available at https://trac.edgewall.org/. 13 14from trac.db import Table, Column, Index, DatabaseManager 15 16def do_upgrade(env, ver, cursor): 17 """Rename the columns `kind` and `change` in the `node_change` table for 18 compatibity with MySQL. 19 """ 20 cursor.execute("CREATE TEMPORARY TABLE nc_old AS SELECT * FROM node_change") 21 cursor.execute("DROP TABLE node_change") 22 23 table = Table('node_change', key=('rev', 'path', 'change_type'))[ 24 Column('rev'), 25 Column('path'), 26 Column('node_type', size=1), 27 Column('change_type', size=1), 28 Column('base_path'), 29 Column('base_rev'), 30 Index(['rev']) 31 ] 32 db_connector, _ = DatabaseManager(env).get_connector() 33 for stmt in db_connector.to_sql(table): 34 cursor.execute(stmt) 35 36 cursor.execute("INSERT INTO node_change (rev,path,node_type,change_type," 37 "base_path,base_rev) SELECT rev,path,kind,change," 38 "base_path,base_rev FROM nc_old") 39 cursor.execute("DROP TABLE nc_old") 40