| 83 | } |
| 84 | |
| 85 | func SquashDeleteAPI(c *gin.Context) { |
| 86 | sourcePtr, ok := c.Get("filedir") |
| 87 | if !ok { |
| 88 | return |
| 89 | } |
| 90 | |
| 91 | sourceURL := sourcePtr.(*url.URL) |
| 92 | |
| 93 | var request squashDeleteRequest |
| 94 | // Bind Request body to Request struct |
| 95 | if c.BindJSON(&request) != nil { |
| 96 | c.JSON(500, &Response{Code: "internal_error", Message: "Something went wrong"}) |
| 97 | return |
| 98 | } |
| 99 | |
| 100 | for _, v := range request.Versions { |
| 101 | delOptions := mig.CreateOptions{ |
| 102 | Version: strconv.FormatInt(v, 10), |
| 103 | Directory: sourceURL.Path, |
| 104 | } |
| 105 | err := delOptions.Delete() |
| 106 | if err != nil { |
| 107 | c.JSON(500, &Response{Code: "internal_error", Message: "Something went wrong"}) |
| 108 | return |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | c.JSON(http.StatusOK, gin.H{"message": "Migrations deleted"}) |
| 113 | } |