@startuml
!define table(x) class x << (T,#FFAAAA) >>
!define primary_key(x) <u>x</u>
!define foreign_key(x) <i><u>x</u></i>
hide methods
hide stereotypes

table(goals) {
    primary_key(id: Integer)
    uuid : String[36]
    name : String[63]
    display_name : String[63]
    efficacy_specification : JSONEncodedList, nullable

    created_at : DateTime
    updated_at : DateTime
    deleted_at : DateTime
    deleted : Integer
}


table(strategies) {
    primary_key(id: Integer)
    foreign_key(goal_id : Integer)
    uuid : String[36]
    name : String[63]
    display_name : String[63]
    parameters_spec : JSONEncodedDict, nullable

    created_at : DateTime
    updated_at : DateTime
    deleted_at : DateTime
    deleted : Integer
}


table(audit_templates) {
    primary_key(id: Integer)
    foreign_key("goal_id : Integer")
    foreign_key("strategy_id : Integer, nullable")
    uuid : String[36]
    name : String[63], nullable
    description : String[255], nullable
    scope : JSONEncodedList

    created_at : DateTime
    updated_at : DateTime
    deleted_at : DateTime
    deleted : Integer
}


table(audits) {
    primary_key(id: Integer)
    foreign_key("goal_id : Integer")
    foreign_key("strategy_id : Integer, nullable")
    uuid : String[36]
    audit_type : String[20]
    state : String[20], nullable
    interval : Integer, nullable
    parameters : JSONEncodedDict, nullable
    scope : JSONEncodedList, nullable
    auto_trigger: Boolean

    created_at : DateTime
    updated_at : DateTime
    deleted_at : DateTime
    deleted : Integer
}


table(action_plans) {
    primary_key(id: Integer)
    foreign_key("audit_id : Integer, nullable")
    foreign_key("strategy_id : Integer")
    uuid : String[36]
    state : String[20], nullable
    global_efficacy : JSONEncodedList, nullable

    created_at : DateTime
    updated_at : DateTime
    deleted_at : DateTime
    deleted : Integer
}


table(actions) {
    primary_key(id: Integer)
    foreign_key("action_plan_id : Integer")
    uuid : String[36]
    action_type : String[255]
    input_parameters : JSONEncodedDict, nullable
    state : String[20], nullable
    parents : JSONEncodedList, nullable

    created_at : DateTime
    updated_at : DateTime
    deleted_at : DateTime
    deleted : Integer
}


table(efficacy_indicators) {
    primary_key(id: Integer)
    foreign_key("action_plan_id : Integer")
    uuid : String[36]
    name : String[63]
    description : String[255], nullable
    unit : String[63], nullable
    value : Numeric

    created_at : DateTime
    updated_at : DateTime
    deleted_at : DateTime
    deleted : Integer
}

table(scoring_engines) {
    primary_key(id: Integer)
    uuid : String[36]
    name : String[63]
    description : String[255], nullable
    metainfo : Text, nullable

    created_at : DateTime
    updated_at : DateTime
    deleted_at : DateTime
    deleted : Integer
}

table(service) {
    primary_key(id: Integer)
    name: String[255]
    host: String[255]
    last_seen_up: DateTime

    created_at : DateTime
    updated_at : DateTime
    deleted_at : DateTime
    deleted : Integer
}

 "goals" <.. "strategies" : Foreign Key
 "goals" <.. "audit_templates" : Foreign Key
 "strategies" <.. "audit_templates" : Foreign Key
 "goals" <.. "audits" : Foreign Key
 "strategies" <.. "audits" : Foreign Key
 "action_plans" <.. "actions" : Foreign Key
 "action_plans" <.. "efficacy_indicators" : Foreign Key
 "strategies" <.. "action_plans" : Foreign Key
 "audits" <.. "action_plans" : Foreign Key

@enduml
