Skip to content

Commit 1a94d2e

Browse files
Merge pull request #27 from Black-Sirius69/master
2 parents d61cfbf + f69b5f6 commit 1a94d2e

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

db/migrations/005_foreign_keys.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ADD CONSTRAINT fk_teams
1818
FOREIGN KEY (team_id)
1919
REFERENCES teams(id)
2020
ON UPDATE CASCADE
21-
ON DELETE CASCADE;
21+
ON DELETE SET NULL;
2222

2323
ALTER TABLE vit_details
2424
ADD CONSTRAINT fk_details

db/migrations/006_teams_key.sql

Lines changed: 0 additions & 9 deletions
This file was deleted.

internal/controllers/team_controller.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,6 @@ func LeaveTeam(ctx echo.Context) error {
244244
})
245245
}
246246

247-
if err := services.UpdateUserTeamDetails(uuid.Nil, user.ID); err != nil {
248-
return ctx.JSON(http.StatusInternalServerError, map[string]string{
249-
"message": err.Error(),
250-
"status": "failed to leave team",
251-
})
252-
}
253-
254247
if team.LeaderID == user.ID {
255248
if err := services.DeleteTeam(user.TeamID, user.ID); err != nil {
256249
return ctx.JSON(http.StatusInternalServerError, map[string]string{
@@ -265,6 +258,13 @@ func LeaveTeam(ctx echo.Context) error {
265258
})
266259
}
267260

261+
if err := services.UpdateUserTeamDetails(uuid.Nil, user.ID); err != nil {
262+
return ctx.JSON(http.StatusInternalServerError, map[string]string{
263+
"message": err.Error(),
264+
"status": "failed to leave team",
265+
})
266+
}
267+
268268
return ctx.JSON(http.StatusOK, map[string]string{
269269
"message": "team left successfully",
270270
"status": "success",

0 commit comments

Comments
 (0)