fix: set repo_id for migrated attachment (#12357)
Was not required until ce0a376723 added extra checks which did require `repo_id` of the attachment to be set correctly.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12357
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
This commit is contained in:
@@ -608,6 +608,7 @@ func InsertReleases(ctx context.Context, rels ...*Release) error {
|
||||
if len(rel.Attachments) > 0 {
|
||||
for i := range rel.Attachments {
|
||||
rel.Attachments[i].ReleaseID = rel.ID
|
||||
rel.Attachments[i].RepoID = rel.RepoID
|
||||
}
|
||||
|
||||
if _, err := sess.NoAutoTime().Insert(rel.Attachments); err != nil {
|
||||
|
||||
@@ -20,11 +20,14 @@ func TestMigrate_InsertReleases(t *testing.T) {
|
||||
UUID: "a0eebc91-9c0c-4ef7-bb6e-6bb9bd380a12",
|
||||
}
|
||||
r := &Release{
|
||||
RepoID: 1001,
|
||||
Attachments: []*Attachment{a},
|
||||
}
|
||||
|
||||
err := InsertReleases(db.DefaultContext, r)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.EqualValues(t, 1001, unittest.AssertExistsAndLoadBean(t, &Attachment{UUID: "a0eebc91-9c0c-4ef7-bb6e-6bb9bd380a12"}).RepoID)
|
||||
}
|
||||
|
||||
func TestReleaseLoadRepo(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user