From 59fc29db383142586b6ac5cab7b324f16553e561 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 17 Dec 2019 14:58:30 +0800 Subject: [PATCH] fix wrong migration (#9381) --- models/migrations/v112.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/migrations/v112.go b/models/migrations/v112.go index c1087b0c47..2c4f659675 100644 --- a/models/migrations/v112.go +++ b/models/migrations/v112.go @@ -20,6 +20,7 @@ func removeAttachmentMissedRepo(x *xorm.Engine) error { attachments := make([]*Attachment, 0, 50) for { err := x.Select("uuid").Where(builder.NotIn("release_id", builder.Select("id").From("`release`"))). + And("release_id > 0"). OrderBy("id").Limit(50, start).Find(&attachments) if err != nil { return err @@ -36,6 +37,6 @@ func removeAttachmentMissedRepo(x *xorm.Engine) error { attachments = attachments[:0] } - _, err := x.Exec("DELETE FROM attachment WHERE release_id NOT IN (SELECT id FROM `release`)") + _, err := x.Exec("DELETE FROM attachment WHERE release_id > 0 AND release_id NOT IN (SELECT id FROM `release`)") return err } -- 2.39.5