Package trac :: Package upgrades :: Module db15

Source Code for Module trac.upgrades.db15

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (C) 2005-2023 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   
14  from trac.db import Table, Column, DatabaseManager 
15   
16 -def do_upgrade(env, ver, cursor):
17 cursor.execute(""" 18 CREATE TEMPORARY TABLE session_old AS SELECT * FROM session 19 """) 20 cursor.execute("DROP TABLE session") 21 22 session_table = Table('session', key=('sid', 'authenticated', 'var_name'))[ 23 Column('sid'), 24 Column('authenticated', type='int'), 25 Column('var_name'), 26 Column('var_value')] 27 db_backend, _ = DatabaseManager(env).get_connector() 28 for stmt in db_backend.to_sql(session_table): 29 cursor.execute(stmt) 30 31 cursor.execute(""" 32 INSERT INTO session (sid,authenticated,var_name,var_value) 33 SELECT sid,authenticated,var_name,var_value FROM session_old 34 """) 35 cursor.execute("DROP TABLE session_old")
36