class CI(Model): __tablename__ = "c_cis" type_id = db.Column(db.Integer, db.ForeignKey("c_ci_types.id"), nullable=False) status = db.Column(db.Enum(*CIStatusEnum.all(), name="status")) heartbeat = db.Column(db.DateTime, default=lambda: datetime.datetime.now()) ci_type = db.relationship("CIType", backref="c_cis.type_id")
class CIRelationHistory(Model): __tablename__ = "c_relation_histories" operate_type = db.Column(db.Enum(OperateType.ADD, OperateType.DELETE, name="operate_type")) record_id = db.Column(db.Integer, db.ForeignKey("c_records.id"), nullable=False) first_ci_id = db.Column(db.Integer) second_ci_id = db.Column(db.Integer) relation_type_id = db.Column(db.Integer, db.ForeignKey("c_relation_types.id")) relation_id = db.Column(db.Integer, nullable=False)
class AttributeHistory(Model): __tablename__ = "c_attribute_histories" operate_type = db.Column(db.Enum(*OperateType.all(), name="operate_type")) record_id = db.Column(db.Integer, db.ForeignKey("c_records.id"), nullable=False) ci_id = db.Column(db.Integer, index=True, nullable=False) attr_id = db.Column(db.Integer, index=True) old = db.Column(db.Text) new = db.Column(db.Text)
class Attribute(Model): __tablename__ = "c_attributes" name = db.Column(db.String(32), nullable=False) alias = db.Column(db.String(32), nullable=False) value_type = db.Column(db.Enum(*ValueTypeEnum.all()), default=ValueTypeEnum.TEXT, nullable=False) is_choice = db.Column(db.Boolean, default=False) is_list = db.Column(db.Boolean, default=False) is_unique = db.Column(db.Boolean, default=False) is_index = db.Column(db.Boolean, default=False) is_link = db.Column(db.Boolean, default=False) is_password = db.Column(db.Boolean, default=False) is_sortable = db.Column(db.Boolean, default=False)
class AttributeHistory(Model): __tablename__ = "c_attribute_histories" ADD = "0" DELETE = "1" UPDATE = "2" operate_type = db.Column(db.Enum(ADD, DELETE, UPDATE, name="operate_type")) record_id = db.Column(db.Integer, db.ForeignKey("c_records.id"), nullable=False) ci_id = db.Column(db.Integer, index=True, nullable=False) attr_id = db.Column(db.Integer, index=True) old = db.Column(db.Text) new = db.Column(db.Text)
class Attribute(Model): __tablename__ = "c_attributes" INT = "0" FLOAT = "1" TEXT = "2" DATETIME = "3" DATE = "4" TIME = "5" name = db.Column(db.String(32), nullable=False) alias = db.Column(db.String(32), nullable=False) value_type = db.Column(db.Enum(INT, FLOAT, TEXT, DATETIME, DATE, TIME), default=TEXT, nullable=False) is_choice = db.Column(db.Boolean, default=False) is_list = db.Column(db.Boolean, default=False) is_unique = db.Column(db.Boolean, default=False) is_index = db.Column(db.Boolean, default=False) is_link = db.Column(db.Boolean, default=False) is_password = db.Column(db.Boolean, default=False) is_sortable = db.Column(db.Boolean, default=False)