Files
Gitea/modelmigration/v1_26/v325.go
T
2026-08-03 08:13:15 +00:00

21 lines
706 B
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v1_26
import (
"context"
"gitea.dev/modelmigration/base"
)
func FixMissedRepoIDWhenMigrateAttachments(_ context.Context, x base.EngineMigration) error {
_, err := x.Exec("UPDATE `attachment` SET `repo_id` = (SELECT `repo_id` FROM `issue` WHERE `issue`.`id` = `attachment`.`issue_id`) WHERE `issue_id` > 0 AND (`repo_id` IS NULL OR `repo_id` = 0);")
if err != nil {
return err
}
_, err = x.Exec("UPDATE `attachment` SET `repo_id` = (SELECT `repo_id` FROM `release` WHERE `release`.`id` = `attachment`.`release_id`) WHERE `release_id` > 0 AND (`repo_id` IS NULL OR `repo_id` = 0);")
return err
}