source: tagsplugin/trunk/tractags/upgrades/db2.py

Last change on this file was 16923, checked in by Ryan J Ollos, 6 years ago

0.10dev: Replace uses of deprecated method

Refs #12788.

File size: 1.0 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# Copyright (C) 2012-2013 Steffen Hoffmann <hoff.st@web.de>
4#
5# This software is licensed as described in the file COPYING, which
6# you should have received as part of this distribution.
7#
8
9from trac.db import Table, Column, Index, DatabaseManager
10
11schema = [
12    Table('tags', key=('tagspace', 'name', 'tag'))[
13        Column('tagspace'),
14        Column('name'),
15        Column('tag'),
16        Index(['tagspace', 'name']),
17        Index(['tagspace', 'tag']),
18    ]
19]
20
21
22def do_upgrade(env, ver, cursor):
23    """Move to new, tractags db schema."""
24
25    connector = DatabaseManager(env).get_connector()[0]
26    for table in schema:
27        for stmt in connector.to_sql(table):
28            cursor.execute(stmt)
29    # Migrate ancient wiki tags table.
30    cursor.execute("""
31        INSERT INTO tags
32               (tagspace, name, tag)
33            SELECT 'wiki', name, namespace
34              FROM wiki_namespace
35        """)
36    # Drop old table `wiki_namespace` (including index `wiki_namespace_idx`).
37    cursor.execute("DROP TABLE wiki_namespace")
Note: See TracBrowser for help on using the repository browser.