本文整理汇总了Python中trac.db.DatabaseManager.upgrade_tables方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.upgrade_tables方法的具体用法?Python DatabaseManager.upgrade_tables怎么用?Python DatabaseManager.upgrade_tables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.db.DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager.upgrade_tables方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_upgrade
# 需要导入模块: from trac.db import DatabaseManager [as 别名]
# 或者: from trac.db.DatabaseManager import upgrade_tables [as 别名]
def do_upgrade(env, ver, cursor):
"""Add a column to the log table for storing the complete request.
Add table required for spam reports by users.
Add table required for filtering statistics.
"""
changed_tables = [
Table('spamfilter_log', key='id')[
Column('id', auto_increment=True),
Column('time', type='int'),
Column('path'),
Column('author'),
Column('authenticated', type='int'),
Column('ipnr'),
Column('headers'),
Column('content'),
Column('rejected', type='int'),
Column('karma', type='int'),
Column('reasons'),
Column('request')
]
]
new_tables = [
Table('spamfilter_statistics',
key=('strategy', 'action', 'data', 'status'))[
Column('strategy'),
Column('action'),
Column('data'),
Column('status'),
Column('delay', type='double precision'),
Column('delay_max', type='double precision'),
Column('delay_min', type='double precision'),
Column('count', type='int'),
Column('external', type='int'),
Column('time', type='int')
],
Table('spamfilter_report', key='id')[
Column('id', auto_increment=True),
Column('entry'),
Column('headers'),
Column('author'),
Column('authenticated', type='int'),
Column('comment'),
Column('time', type='int')
]
]
dbm = DatabaseManager(env)
dbm.create_tables(new_tables)
dbm.upgrade_tables(changed_tables)