]> source.dussan.org Git - gitea.git/commitdiff
fix wrong migration (#9381)
authorLunny Xiao <xiaolunwen@gmail.com>
Tue, 17 Dec 2019 06:58:30 +0000 (14:58 +0800)
committerGitHub <noreply@github.com>
Tue, 17 Dec 2019 06:58:30 +0000 (14:58 +0800)
models/migrations/v112.go

index c1087b0c47c53dd014f85601b806c63556030774..2c4f659675c05b57aad768eed4a350659b2ed02b 100644 (file)
@@ -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
 }