Пример #1
0
class Tickets(db.Model):
    __tablename__ = "tickets"
    id = db.Column(db.Integer,
                   primary_key=True,
                   autoincrement=True,
                   comment="ID")
    tickets_num = db.Column(db.BigInteger,
                            nullable=False,
                            index=True,
                            comment="工单编号",
                            unique=True)
    applicant = db.Column(db.String(16),
                          nullable=False,
                          index=True,
                          comment="提交人")
    auditor = db.Column(db.String(16), nullable=False, comment="审核人")
    sqlcontent = db.Column(db.Text, nullable=False, comment="待审核的语句内容")
    db_id = db.Column(db.Integer, db.ForeignKey('mysql_databases.id'))
    status = db.Column(db.String(16),
                       nullable=False,
                       server_default='',
                       default='',
                       comment="工单状态")
    is_execute = db.Column(db.SmallInteger,
                           nullable=False,
                           default=0,
                           comment="工单是否已经执行")
    is_delete = db.Column(db.SmallInteger,
                          nullable=False,
                          default=0,
                          comment="工单逻辑删除,0:正常,1:删除")
    audit_advise = db.Column(db.Text,
                             nullable=False,
                             default='',
                             comment='审核意见')
    introduction = db.Column(db.String(10),
                             nullable=False,
                             default='',
                             comment="工单简介")
    type = db.Column(db.String(6),
                     nullable=False,
                     default='',
                     comment="工单类型:DML,DDL")
    add_time = db.Column(db.DateTime,
                         default=datetime.now(),
                         comment="提交时间",
                         index=True)
    last_modify_time = db.Column(db.DateTime,
                                 nullable=False,
                                 default=datetime.now(),
                                 onupdate=datetime.now(),
                                 comment="最后变更时间")

    def __repr__(self):
        return '<Tickets %r >' % (self.id)
Пример #2
0
class MySQL_Databases(db.Model):
    __tablename__ = 'mysql_databases'
    id = db.Column(db.Integer,
                   primary_key=True,
                   autoincrement=True,
                   comment="主键ID")
    name = db.Column(db.String(32), index=True, unique=True, comment="名称(标识)")
    cluster_id = db.Column(db.Integer,
                           db.ForeignKey('db_cluster.id'),
                           comment="集群ID")
    datacenter_id = db.Column(db.Integer,
                              db.ForeignKey('data_center.id'),
                              comment="所属数据库中心")
    version = db.Column(db.String(16),
                        nullable=False,
                        default='',
                        comment="版本号")
    ip = db.Column(db.String(16), nullable=False, index=True, comment="IP地址")
    port = db.Column(db.Integer, nullable=False, comment="端口")
    is_master = db.Column(db.SmallInteger,
                          nullable=False,
                          default=0,
                          comment="是否主库,0否1是")
    is_slave = db.Column(db.SmallInteger,
                         nullable=False,
                         default=0,
                         comment="是否从库,0否1是")
    status = db.Column(db.String(10),
                       nullable=False,
                       default='unknown',
                       comment="active:正常,inactive:出错,unknown:未知状态")
    applicant = db.Column(db.String(16), nullable=False, comment="申请人")
    introduction = db.Column(db.String(8), comment="说明简介")
    add_time = db.Column(db.DateTime, default=datetime.now())
    last_modify_time = db.Column(db.DateTime,
                                 default=datetime.now(),
                                 onupdate=datetime.now())
    tickets = db.relationship('Tickets', backref='mysql_databases')

    def __repr__(self):
        return '<Databases %r>' % (self.name)
Пример #3
0
class User(db.Model,UserMixin):
    __tablename__ = 'users'
    id = db.Column(db.Integer,primary_key=True,autoincrement=True,comment="用户ID")
    username = db.Column(db.String(64),nullable=False,default='',server_default='',unique=True,index=True,comment="用户名")
    password = db.Column(db.String(128),nullable=False,default='',server_default='',comment="密码")
    real_name = db.Column(db.String(16),nullable=False,default='',server_default='',index=True,comment="真实姓名")
    email = db.Column(db.String(64),nullable=False,default='',server_default='',unique=True,index=True,comment="邮件地址")
    status = db.Column(db.String(10),index=True,nullable=False,default='',server_default='',comment="状态")
    group_id = db.Column(db.Integer, db.ForeignKey('user_group.id'),comment="用户组ID")
    privileges = db.Column(db.String(256),nullable=False,default='',server_default='',comment="url权限")
    add_time = db.Column(db.DateTime,default=datetime.now,comment="添加日期")
    last_modify_time = db.Column(db.DateTime,default=datetime.now,onupdate=datetime.now,comment="最后更新时间")
    def __repr__(self):
        return '<User %r>' % (self.username)