code.gitea.io/gitea@v1.21.7/models/migrations/v1_13/v144.go (about)

     1  // Copyright 2020 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package v1_13 //nolint
     5  
     6  import (
     7  	"code.gitea.io/gitea/modules/log"
     8  
     9  	"xorm.io/builder"
    10  	"xorm.io/xorm"
    11  )
    12  
    13  func UpdateMatrixWebhookHTTPMethod(x *xorm.Engine) error {
    14  	matrixHookTaskType := 9 // value comes from the models package
    15  	type Webhook struct {
    16  		HTTPMethod string
    17  	}
    18  
    19  	cond := builder.Eq{"hook_task_type": matrixHookTaskType}.And(builder.Neq{"http_method": "PUT"})
    20  	count, err := x.Where(cond).Cols("http_method").Update(&Webhook{HTTPMethod: "PUT"})
    21  	if err == nil {
    22  		log.Debug("Updated %d Matrix webhooks with http_method 'PUT'", count)
    23  	}
    24  	return err
    25  }