Skip to content

Commit 96b44fe

Browse files
committed
RHINENG-25900: grant permissions after pg_repack recreate
1 parent 6d0becb commit 96b44fe

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

turnpike/controllers/database.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ type Session struct {
2424
// @Failure 500 {object} map[string]interface{}
2525
// @Router /database/pg_repack/recreate [put]
2626
func RepackRecreateHandler(c *gin.Context) {
27-
if err := database.DB.Exec("DROP EXTENSION IF EXISTS pg_repack CASCADE").Error; err != nil {
28-
c.JSON(http.StatusInternalServerError, gin.H{"err": err.Error()})
29-
return
27+
runSequence := []string{
28+
"DROP EXTENSION IF EXISTS pg_repack CASCADE",
29+
"CREATE EXTENSION pg_repack",
30+
"GRANT USAGE ON SCHEMA repack TO vmaas_sync",
3031
}
31-
if err := database.DB.Exec("CREATE EXTENSION pg_repack").Error; err != nil {
32-
c.JSON(http.StatusInternalServerError, gin.H{"err": err.Error()})
32+
for _, query := range runSequence {
33+
if err := database.DB.Exec(query).Error; err != nil {
34+
c.JSON(http.StatusInternalServerError, gin.H{"err": err.Error()})
35+
return
36+
}
3337
}
3438
c.JSON(http.StatusOK, "pg_repack extension re-created")
3539
}

0 commit comments

Comments
 (0)