24 lines
878 B
Go
24 lines
878 B
Go
package organizationdb
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/tech/sendico/pkg/mutil/mzap"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// DeleteCascade deletes an organization and all its related data (projects, tasks, comments, reactions, statuses)
|
|
func (db *OrganizationDB) DeleteCascade(ctx context.Context, organizationRef primitive.ObjectID) error {
|
|
db.DBImp.Logger.Debug("Starting organization deletion with projects", mzap.ObjRef("organization_ref", organizationRef))
|
|
|
|
// Delete the organization itself
|
|
if err := db.Unprotected().Delete(ctx, organizationRef); err != nil {
|
|
db.DBImp.Logger.Warn("Error deleting organization", zap.Error(err), mzap.ObjRef("organization_ref", organizationRef))
|
|
return err
|
|
}
|
|
|
|
db.DBImp.Logger.Debug("Successfully deleted organization with projects", mzap.ObjRef("organization_ref", organizationRef))
|
|
return nil
|
|
}
|