SharedWorkflowGraph
    hash        WorkflowGraphReference
    graph       (WorkflowGraph FileReference SqlBackendKey) -- UserId
    Primary     hash
    deriving Generic

WorkflowDefinition
    graph       SharedWorkflowGraphId
    scope       WorkflowScope'
    name        WorkflowDefinitionName 
    instanceCategory WorkflowInstanceCategory Maybe
    UniqueWorkflowDefinition name scope
    deriving Generic

WorkflowDefinitionDescription
    definition  WorkflowDefinitionId OnDeleteCascade OnUpdateCascade
    language    Lang
    title       Text
    description StoredMarkup Maybe
    UniqueWorkflowDefinitionDescription definition language
    deriving Generic

WorkflowDefinitionInstanceDescription
    definition  WorkflowDefinitionId OnDeleteCascade OnUpdateCascade
    language    Lang
    title       Text
    description StoredMarkup Maybe
    UniqueWorkflowDefinitionInstanceDescription definition language
    deriving Generic

WorkflowInstance
    definition  WorkflowDefinitionId Maybe OnDeleteSetNull OnUpdateCascade
    graph       SharedWorkflowGraphId
    scope       (WorkflowScope TermIdentifier SchoolShorthand SqlBackendKey)  -- TermId, SchoolId, CourseId
    name        WorkflowInstanceName
    category    WorkflowInstanceCategory Maybe
    UniqueWorkflowInstance name scope
    deriving Generic
    
WorkflowInstanceDescription
    instance    WorkflowInstanceId
    language    Lang
    title       Text
    description StoredMarkup Maybe
    UniqueWorkflowInstanceDescription instance language
    deriving Generic

WorkflowWorkflow
    instance    WorkflowInstanceId Maybe
    scope       (WorkflowScope TermIdentifier SchoolShorthand SqlBackendKey)  -- TermId, SchoolId, CourseId
    graph       SharedWorkflowGraphId
    state       (WorkflowState FileReference SqlBackendKey)  -- UserId
    deriving Generic
