2019-12-31 21:32:47 +00:00
|
|
|
import enum
|
|
|
|
|
|
|
|
from marshmallow_enum import EnumField
|
2020-01-03 16:44:24 +00:00
|
|
|
from marshmallow_sqlalchemy import ModelSchema
|
2019-12-31 21:32:47 +00:00
|
|
|
from sqlalchemy import func
|
|
|
|
|
|
|
|
from crc import db
|
|
|
|
|
|
|
|
|
|
|
|
class FileType(enum.Enum):
|
|
|
|
bpmn = "bpmm"
|
|
|
|
svg = "svg"
|
|
|
|
dmn = "dmn"
|
|
|
|
|
|
|
|
|
|
|
|
class FileDataModel(db.Model):
|
|
|
|
__tablename__ = 'file_data'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
data = db.Column(db.LargeBinary)
|
|
|
|
file_model_id = db.Column(db.Integer, db.ForeignKey('file.id'))
|
|
|
|
file_model = db.relationship("FileModel")
|
|
|
|
|
2020-01-03 16:44:24 +00:00
|
|
|
|
2019-12-31 21:32:47 +00:00
|
|
|
class FileModel(db.Model):
|
|
|
|
__tablename__ = 'file'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
name = db.Column(db.String)
|
|
|
|
version = db.Column(db.Integer, default=0)
|
|
|
|
last_updated = db.Column(db.DateTime(timezone=True), default=func.now())
|
|
|
|
type = db.Column(db.Enum(FileType))
|
|
|
|
primary = db.Column(db.Boolean)
|
|
|
|
content_type = db.Column(db.String)
|
2020-01-13 22:52:37 +00:00
|
|
|
workflow_spec_id = db.Column(db.String, db.ForeignKey('workflow_spec.id'))
|
2019-12-31 21:32:47 +00:00
|
|
|
|
|
|
|
|
2020-01-03 16:44:24 +00:00
|
|
|
class FileModelSchema(ModelSchema):
|
2019-12-31 21:32:47 +00:00
|
|
|
class Meta:
|
|
|
|
model = FileModel
|
2020-01-13 22:52:37 +00:00
|
|
|
include_fk = True # Includes foreign keys
|
2019-12-31 21:32:47 +00:00
|
|
|
type = EnumField(FileType)
|
|
|
|
|
|
|
|
|