class Case(db.Model): __tablename__ = "case" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text(500), nullable=False) scenario_id = db.Column(db.Integer, db.ForeignKey('scenario.id')) state_code = db.Column(db.Enum(StateType)) def __init__(self, name, scenario_id): self.name = name self.scenario_id = scenario_id self.state_code = StateType.active
class CycleScenarios(db.Model): __tablename__ = "cycle_scenarios" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) cycle_id = db.Column(db.Integer, db.ForeignKey('cycle.id')) state_code = db.Column(db.Enum(StateType)) scenario_id = db.Column(db.Integer, db.ForeignKey('scenario.id')) last_executed_by = db.Column(db.Integer, db.ForeignKey('user.id')) last_executed_at = db.Column(db.DateTime) def __init__(self, cycle_id, scenario_id): self.cycle_id = cycle_id self.scenario_id = scenario_id self.state_code = StateType.not_executed
class Scenario(db.Model): __tablename__ = "scenario" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text, nullable=False) state_code = db.Column(db.Enum(StateType)) project_id = db.Column(db.Integer, db.ForeignKey('project.id')) cycle_scenarios = db.relationship('CycleScenarios') cycle_cases = db.relationship('CycleCases') case = db.relationship('Case') def __init__(self, name, project_id): self.name = name self.project_id = project_id self.state_code = StateType.active
class Cycle(db.Model): __tablename__ = "cycle" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) cycle = db.Column(db.Integer, nullable=False) name = db.Column(db.Text) project_id = db.Column(db.Integer, db.ForeignKey('project.id')) state_code = db.Column(db.Enum(StateType)) cycle_cases = db.relationship('CycleCases') cycle_scenarios = db.relationship('CycleScenarios') created_at = db.Column(db.DateTime, default=datetime.now) closed_at = db.Column(db.DateTime) closed_by = db.Column(db.Integer, db.ForeignKey('user.id')) closed_reason = db.Column(db.String(250)) last_change = db.Column(db.DateTime, default=datetime.now) def __init__(self, cycle, name, project_id): self.cycle = cycle self.name = name self.project_id = project_id self.state_code = StateType.active