diff --git a/api/archetype.go b/api/archetype.go index 221f4cff..8f4488d9 100644 --- a/api/archetype.go +++ b/api/archetype.go @@ -57,14 +57,6 @@ func (h ArchetypeHandler) Get(ctx *gin.Context) { return } - archetypes := []model.Archetype{} - db = h.preLoad(h.DB(ctx), "Tags", "CriteriaTags") - result = db.Find(&archetypes) - if result.Error != nil { - _ = ctx.Error(result.Error) - return - } - membership := assessment.NewMembershipResolver(h.DB(ctx)) applications, err := membership.Applications(m) if err != nil { @@ -325,6 +317,7 @@ type Archetype struct { StakeholderGroups []Ref `json:"stakeholderGroups" yaml:"stakeholderGroups"` Applications []Ref `json:"applications" yaml:"applications"` Assessments []Ref `json:"assessments" yaml:"assessments"` + Review *Ref `json:"review"` } // @@ -354,6 +347,11 @@ func (r *Archetype) With(m *model.Archetype) { for _, a := range m.Assessments { r.Assessments = append(r.Assessments, r.ref(a.ID, &a)) } + if m.Review != nil { + ref := &Ref{} + ref.With(m.Review.ID, "") + r.Review = ref + } } // diff --git a/migration/v9/model/archetype.go b/migration/v9/model/archetype.go index bb272210..79573247 100644 --- a/migration/v9/model/archetype.go +++ b/migration/v9/model/archetype.go @@ -7,8 +7,8 @@ type Archetype struct { Comments string Review *Review `gorm:"constraint:OnDelete:CASCADE"` Assessments []Assessment `gorm:"constraint:OnDelete:CASCADE"` - CriteriaTags []Tag `gorm:"many2many:ArchetypeCriteriaTags"` - Tags []Tag `gorm:"many2many:ArchetypeTags"` + CriteriaTags []Tag `gorm:"many2many:ArchetypeCriteriaTags;constraint:OnDelete:CASCADE"` + Tags []Tag `gorm:"many2many:ArchetypeTags;constraint:OnDelete:CASCADE"` Stakeholders []Stakeholder `gorm:"many2many:ArchetypeStakeholders;constraint:OnDelete:CASCADE"` StakeholderGroups []StakeholderGroup `gorm:"many2many:ArchetypeStakeholderGroups;constraint:OnDelete:CASCADE"` }