| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2016 Cinc |
|---|
| 4 | # All rights reserved. |
|---|
| 5 | # |
|---|
| 6 | # This software is licensed as described in the file COPYING.txt, which |
|---|
| 7 | # you should have received as part of this distribution. |
|---|
| 8 | # |
|---|
| 9 | # Author: Cinc |
|---|
| 10 | # |
|---|
| 11 | from trac.db import Table, Column, DatabaseManager |
|---|
| 12 | |
|---|
| 13 | #The tables for the Code Review Plugin database version 1 |
|---|
| 14 | |
|---|
| 15 | tables = [ |
|---|
| 16 | Table('CodeReviews', key='IDReview')[ |
|---|
| 17 | Column('IDReview', auto_increment=True, type='int'), |
|---|
| 18 | Column('Author'), |
|---|
| 19 | Column('Status'), |
|---|
| 20 | Column('DateCreate', type='int'), |
|---|
| 21 | Column('Name'), |
|---|
| 22 | Column('Notes'), |
|---|
| 23 | ], |
|---|
| 24 | Table('Reviewers', key=('IDReview', 'Reviewer'))[ |
|---|
| 25 | Column('IDReview', type='int'), |
|---|
| 26 | Column('Reviewer'), |
|---|
| 27 | Column('Status', type='int'), |
|---|
| 28 | Column('Vote', type='int'), |
|---|
| 29 | ], |
|---|
| 30 | Table('ReviewFiles', key='IDFile')[ |
|---|
| 31 | Column('IDFile', auto_increment=True, type='int'), |
|---|
| 32 | Column('IDReview', type='int'), |
|---|
| 33 | Column('Path'), |
|---|
| 34 | Column('LineStart', type='int'), |
|---|
| 35 | Column('LineEnd', type='int'), |
|---|
| 36 | Column('Version', type='int'), |
|---|
| 37 | ], |
|---|
| 38 | Table('ReviewComments', key='IDComment')[ |
|---|
| 39 | Column('IDComment', auto_increment=True, type='int'), |
|---|
| 40 | Column('IDFile', type='int'), |
|---|
| 41 | Column('IDParent', type='int'), |
|---|
| 42 | Column('LineNum', type='int'), |
|---|
| 43 | Column('Author'), |
|---|
| 44 | Column('Text'), |
|---|
| 45 | Column('AttachmentPath'), |
|---|
| 46 | Column('DateCreate', type='int'), |
|---|
| 47 | ], |
|---|
| 48 | ] |
|---|
| 49 | |
|---|
| 50 | def do_upgrade(env, ver, cursor): |
|---|
| 51 | """Add tables.""" |
|---|
| 52 | db_connector, _ = DatabaseManager(env).get_connector() |
|---|
| 53 | for tbl in tables: |
|---|
| 54 | for stmt in db_connector.to_sql(tbl): |
|---|
| 55 | cursor.execute(stmt) |
|---|
| 56 | |
|---|
| 57 | cursor.execute("INSERT INTO system VALUES (%s, %s)", ('CodeReviewVoteThreshold', 0)) |
|---|