v19.go 502 B

123456789101112131415161718
  1. // Copyright 2018 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "xorm.io/xorm"
  7. )
  8. func cleanUnlinkedWebhookAndHookTasks(x *xorm.Engine) error {
  9. _, err := x.Exec(`DELETE FROM webhook WHERE repo_id NOT IN (SELECT id FROM repository);`)
  10. if err != nil {
  11. return err
  12. }
  13. _, err = x.Exec(`DELETE FROM hook_task WHERE repo_id NOT IN (SELECT id FROM repository);`)
  14. return err
  15. }