cascade delete services when removing environment

This commit is contained in:
Michael Quigley 2022-11-28 11:40:39 -05:00
parent 4b70a8a0d3
commit c0e22792d0
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -107,6 +107,15 @@ func (self *disableHandler) removeServicesForEnvironment(envId int, tx *sqlx.Tx,
}
func (self *disableHandler) removeEnvironment(envId int, tx *sqlx.Tx) error {
svcs, err := str.FindServicesForEnvironment(envId, tx)
if err != nil {
return errors.Wrapf(err, "error finding services for environment '%d'", envId)
}
for _, svc := range svcs {
if err := str.DeleteService(svc.Id, tx); err != nil {
return errors.Wrapf(err, "error deleting service '%d' for environment '%d'", svc.Id, envId)
}
}
if err := str.DeleteEnvironment(envId, tx); err != nil {
return errors.Wrapf(err, "error deleting environment '%d'", envId)
}