# coding: utf-8 from sqlalchemy import Column, Index, Integer, Table, Text from sqlalchemy.ext.declarative import declarative_base from app import db from datetime import datetime Base = declarative_base() metadata = Base.metadata t_attachment = Table( 'attachment', metadata, Column('type', Text), Column('id', Text), Column('filename', Text), Column('size', Integer), Column('time', Integer), Column('description', Text), Column('author', Text), Column('ipnr', Text) ) t_auth_cookie = Table( 'auth_cookie', metadata, Column('cookie', Text), Column('name', Text), Column('ipnr', Text), Column('time', Integer) ) class Cache(db.Model): __tablename__ = 'cache' id = Column(Text, primary_key=True) generation = Column(Integer) class Component(db.Model): __tablename__ = 'component' name = Column(Text, primary_key=True) owner = Column(Text) description = Column(Text) t_enum = Table( 'enum', metadata, Column('type', Text), Column('name', Text), Column('value', Text) ) class Milestone(db.Model): __tablename__ = 'milestone' name = Column(Text, primary_key=True) due = Column(Integer) completed = Column(Integer) description = Column(Text) t_node_change = Table( 'node_change', metadata, Column('repos', Integer), Column('rev', Text), Column('path', Text), Column('node_type', Text), Column('change_type', Text), Column('base_path', Text), Column('base_rev', Text), Index('node_change_repos_rev_idx', 'repos', 'rev') ) t_permission = Table( 'permission', metadata, Column('username', Text), Column('action', Text) ) class Report(db.Model): __tablename__ = 'report' id = Column(Integer, primary_key=True) author = Column(Text) title = Column(Text) query = Column(Text) description = Column(Text) t_repository = Table( 'repository', metadata, Column('id', Integer), Column('name', Text), Column('value', Text) ) t_revision = Table( 'revision', metadata, Column('repos', Integer), Column('rev', Text), Column('time', Integer), Column('author', Text), Column('message', Text), Index('revision_repos_time_idx', 'repos', 'time') ) t_session = Table( 'session', metadata, Column('sid', Text), Column('authenticated', Integer, index=True), Column('last_visit', Integer, index=True) ) t_session_attribute = Table( 'session_attribute', metadata, Column('sid', Text), Column('authenticated', Integer), Column('name', Text), Column('value', Text) ) class System(db.Model): __tablename__ = 'system' name = Column(Text, primary_key=True) value = Column(Text) class TicketCustom(db.Model): __tablename__ = 'ticket_custom' ticket = Column(Integer, primary_key=True) name = Column(Text, primary_key=True) value = Column(Text) class Ticket(db.Model): __tablename__ = 'ticket' id = Column(Integer, primary_key=True) type = Column(Text) time = Column(Integer, index=True) changetime = Column(Integer) component = Column(Text) severity = Column(Text) priority = Column(Text) owner = Column(Text) reporter = Column(Text) cc = Column(Text) version = Column(Text) milestone = Column(Text) status = Column(Text, index=True) resolution = Column(Text) summary = Column(Text) description = Column(Text) keywords = Column(Text) @property def changetime_f(self): return datetime.fromtimestamp(self.changetime / 1000000) @property def time_f(self): return datetime.fromtimestamp(self.time / 1000000) t_ticket_change = Table( 'ticket_change', metadata, Column('ticket', Integer, index=True), Column('time', Integer, index=True), Column('author', Text), Column('field', Text), Column('oldvalue', Text), Column('newvalue', Text) ) #t_ticket_custom = Table( # 'ticket_custom', metadata, # Column('ticket', Integer), # Column('name', Text), # Column('value', Text) #) class Version(db.Model): __tablename__ = 'version' name = Column(Text, primary_key=True) time = Column(Integer) description = Column(Text) t_wiki = Table( 'wiki', metadata, Column('name', Text), Column('version', Integer), Column('time', Integer, index=True), Column('author', Text), Column('ipnr', Text), Column('text', Text), Column('comment', Text), Column('readonly', Integer) )