models Enum type fix

This commit is contained in:
pycook 2016-04-27 17:38:21 +08:00
parent 4397049988
commit 3b0fc36b07
6 changed files with 10 additions and 14 deletions

View File

@ -8,6 +8,6 @@ def row2dict(row):
(basestring, long, int, float, list, tuple, dict)) \
and getattr(row, c.name):
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)
return d

View File

@ -10,7 +10,6 @@ class CIAttribute(db.Model):
attr_name = db.Column(db.String(32), nullable=False, unique=True)
attr_alias = db.Column(db.String(32), nullable=False, unique=True)
value_type = db.Column(
db.String(8),
db.Enum("int", "float", "text", "datetime", name='value_type'),
default="text",
nullable=False)

View File

@ -14,7 +14,6 @@ class CI(db.Model):
db.ForeignKey("ci_types.type_id"),
nullable=False)
ci_type = db.relationship("CIType", backref="cis")
status = db.Column(db.String(8),
db.Enum("review", "validate", name="stauts"))
status = db.Column(db.Enum("review", "validate", name="status"))
created_time = db.Column(db.DateTime, default=datetime.datetime.now())
heartbeat = db.Column(db.DateTime, default=datetime.datetime.now())

View File

@ -18,8 +18,8 @@ class CIRelation(db.Model):
second_ci = db.relationship(
"CI", primaryjoin="CI.ci_id==CIRelation.second_ci_id")
relation_type = db.Column(
db.String(8), db.Enum("connect", "deploy", "install", "contain",
name="relation_type"), nullable=False)
db.Enum("connect", "deploy", "install", "contain",
name="relation_type"), nullable=False)
more = db.Column(db.Integer, db.ForeignKey("cis.ci_id"))
__table_args__ = (db.UniqueConstraint("first_ci_id", "second_ci_id",

View File

@ -18,7 +18,6 @@ class CITypeRelation(db.Model):
child = db.relationship(
"CIType", primaryjoin="CIType.type_id==CITypeRelation.child_id")
relation_type = db.Column(
db.String(7),
db.Enum("contain", "connect", "deploy", "install",
name="relation_type"),
default="contain")

View File

@ -23,8 +23,8 @@ class CIAttributeHistory(db.Model):
__tablename__ = "histories"
h_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
operate_type = db.Column(db.String(6), db.Enum("add", "delete", "update",
name="operate_type"))
operate_type = db.Column(db.Enum("add", "delete", "update",
name="operate_type"))
record_id = db.Column(db.Integer,
db.ForeignKey("records.record_id"),
nullable=False)
@ -38,14 +38,13 @@ class CIRelationHistory(db.Model):
__tablename__ = "relation_histories"
rh_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
operate_type = db.Column(db.String(6),
db.Enum("add", "delete", name="operate_type"))
operate_type = db.Column(db.Enum("add", "delete", name="operate_type"))
record_id = db.Column(db.Integer,
db.ForeignKey("records.record_id"),
nullable=False)
first_ci_id = db.Column(db.Integer)
second_ci_id = db.Column(db.Integer)
relation_type = db.Column(
db.String(8), db.Enum("connect", "deploy", "install", "contain",
name="relation_type"))
db.Enum("connect", "deploy", "install", "contain",
name="relation_type"))
relation = db.Column(db.Integer, nullable=False)