aboutsummaryrefslogtreecommitdiffstats
path: root/models/migrations/v1_12/v129.go
blob: cf228242b9dfd3b9bb6b46caa4b1c2d026f4a020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package v1_12 //nolint

import (
	"xorm.io/xorm"
)

func PurgeUnusedDependencies(x *xorm.Engine) error {
	if _, err := x.Exec("DELETE FROM issue_dependency WHERE issue_id NOT IN (SELECT id FROM issue)"); err != nil {
		return err
	}
	_, err := x.Exec("DELETE FROM issue_dependency WHERE dependency_id NOT IN (SELECT id FROM issue)")
	return err
}