Source

trac-ticketlinks / trac / upgrades / db27.py

from trac.db import Table, Column, Index, DatabaseManager

def do_upgrade(env, ver, cursor):
    """Add new table for links
    """
    table = Table('ticket_links', key=('source', 'destination', 'type'))[
        Column('source', type='int'),
        Column('destination', type='int'),
        Column('type')]
    db_connector, _ = DatabaseManager(env)._get_connector()
    for stmt in db_connector.to_sql(table):
        cursor.execute(stmt)