1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-15 06:34:25 +00:00
gitea/models/migrations/v1_12/v120.go

20 lines
444 B
Go
Raw Normal View History

// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v1_12 //nolint
import (
"xorm.io/xorm"
)
func AddOwnerNameOnRepository(x *xorm.Engine) error {
type Repository struct {
OwnerName string
}
if err := x.Sync(new(Repository)); err != nil {
return err
}
_, err := x.Exec("UPDATE repository SET owner_name = (SELECT name FROM `user` WHERE `user`.id = repository.owner_id)")
return err
}