mirror of https://github.com/veops/cmdb.git
models Enum type fix
This commit is contained in:
parent
4397049988
commit
3b0fc36b07
|
@ -8,6 +8,6 @@ def row2dict(row):
|
||||||
(basestring, long, int, float, list, tuple, dict)) \
|
(basestring, long, int, float, list, tuple, dict)) \
|
||||||
and getattr(row, c.name):
|
and getattr(row, c.name):
|
||||||
d[c.name] = getattr(row, c.name).strftime("%Y-%m-%d %H:%M:%S")
|
d[c.name] = getattr(row, c.name).strftime("%Y-%m-%d %H:%M:%S")
|
||||||
else:
|
elif c.name not in ("password", "secret"):
|
||||||
d[c.name] = getattr(row, c.name)
|
d[c.name] = getattr(row, c.name)
|
||||||
return d
|
return d
|
|
@ -10,7 +10,6 @@ class CIAttribute(db.Model):
|
||||||
attr_name = db.Column(db.String(32), nullable=False, unique=True)
|
attr_name = db.Column(db.String(32), nullable=False, unique=True)
|
||||||
attr_alias = db.Column(db.String(32), nullable=False, unique=True)
|
attr_alias = db.Column(db.String(32), nullable=False, unique=True)
|
||||||
value_type = db.Column(
|
value_type = db.Column(
|
||||||
db.String(8),
|
|
||||||
db.Enum("int", "float", "text", "datetime", name='value_type'),
|
db.Enum("int", "float", "text", "datetime", name='value_type'),
|
||||||
default="text",
|
default="text",
|
||||||
nullable=False)
|
nullable=False)
|
||||||
|
|
|
@ -14,7 +14,6 @@ class CI(db.Model):
|
||||||
db.ForeignKey("ci_types.type_id"),
|
db.ForeignKey("ci_types.type_id"),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
ci_type = db.relationship("CIType", backref="cis")
|
ci_type = db.relationship("CIType", backref="cis")
|
||||||
status = db.Column(db.String(8),
|
status = db.Column(db.Enum("review", "validate", name="status"))
|
||||||
db.Enum("review", "validate", name="stauts"))
|
|
||||||
created_time = db.Column(db.DateTime, default=datetime.datetime.now())
|
created_time = db.Column(db.DateTime, default=datetime.datetime.now())
|
||||||
heartbeat = db.Column(db.DateTime, default=datetime.datetime.now())
|
heartbeat = db.Column(db.DateTime, default=datetime.datetime.now())
|
|
@ -18,8 +18,8 @@ class CIRelation(db.Model):
|
||||||
second_ci = db.relationship(
|
second_ci = db.relationship(
|
||||||
"CI", primaryjoin="CI.ci_id==CIRelation.second_ci_id")
|
"CI", primaryjoin="CI.ci_id==CIRelation.second_ci_id")
|
||||||
relation_type = db.Column(
|
relation_type = db.Column(
|
||||||
db.String(8), db.Enum("connect", "deploy", "install", "contain",
|
db.Enum("connect", "deploy", "install", "contain",
|
||||||
name="relation_type"), nullable=False)
|
name="relation_type"), nullable=False)
|
||||||
more = db.Column(db.Integer, db.ForeignKey("cis.ci_id"))
|
more = db.Column(db.Integer, db.ForeignKey("cis.ci_id"))
|
||||||
|
|
||||||
__table_args__ = (db.UniqueConstraint("first_ci_id", "second_ci_id",
|
__table_args__ = (db.UniqueConstraint("first_ci_id", "second_ci_id",
|
||||||
|
|
|
@ -18,7 +18,6 @@ class CITypeRelation(db.Model):
|
||||||
child = db.relationship(
|
child = db.relationship(
|
||||||
"CIType", primaryjoin="CIType.type_id==CITypeRelation.child_id")
|
"CIType", primaryjoin="CIType.type_id==CITypeRelation.child_id")
|
||||||
relation_type = db.Column(
|
relation_type = db.Column(
|
||||||
db.String(7),
|
|
||||||
db.Enum("contain", "connect", "deploy", "install",
|
db.Enum("contain", "connect", "deploy", "install",
|
||||||
name="relation_type"),
|
name="relation_type"),
|
||||||
default="contain")
|
default="contain")
|
||||||
|
|
|
@ -23,8 +23,8 @@ class CIAttributeHistory(db.Model):
|
||||||
__tablename__ = "histories"
|
__tablename__ = "histories"
|
||||||
|
|
||||||
h_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
h_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||||
operate_type = db.Column(db.String(6), db.Enum("add", "delete", "update",
|
operate_type = db.Column(db.Enum("add", "delete", "update",
|
||||||
name="operate_type"))
|
name="operate_type"))
|
||||||
record_id = db.Column(db.Integer,
|
record_id = db.Column(db.Integer,
|
||||||
db.ForeignKey("records.record_id"),
|
db.ForeignKey("records.record_id"),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
|
@ -38,14 +38,13 @@ class CIRelationHistory(db.Model):
|
||||||
__tablename__ = "relation_histories"
|
__tablename__ = "relation_histories"
|
||||||
|
|
||||||
rh_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
rh_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||||
operate_type = db.Column(db.String(6),
|
operate_type = db.Column(db.Enum("add", "delete", name="operate_type"))
|
||||||
db.Enum("add", "delete", name="operate_type"))
|
|
||||||
record_id = db.Column(db.Integer,
|
record_id = db.Column(db.Integer,
|
||||||
db.ForeignKey("records.record_id"),
|
db.ForeignKey("records.record_id"),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
first_ci_id = db.Column(db.Integer)
|
first_ci_id = db.Column(db.Integer)
|
||||||
second_ci_id = db.Column(db.Integer)
|
second_ci_id = db.Column(db.Integer)
|
||||||
relation_type = db.Column(
|
relation_type = db.Column(
|
||||||
db.String(8), db.Enum("connect", "deploy", "install", "contain",
|
db.Enum("connect", "deploy", "install", "contain",
|
||||||
name="relation_type"))
|
name="relation_type"))
|
||||||
relation = db.Column(db.Integer, nullable=False)
|
relation = db.Column(db.Integer, nullable=False)
|
||||||
|
|
Loading…
Reference in New Issue