2022-07-30 17:52:04 +02:00
// Copyright 2022 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package migrations
import (
packages_model "code.gitea.io/gitea/models/packages"
container_module "code.gitea.io/gitea/modules/packages/container"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
)
2022-08-08 17:58:11 +02:00
func addContainerRepositoryProperty ( x * xorm . Engine ) ( err error ) {
2022-07-30 17:52:04 +02:00
switch x . Dialect ( ) . URI ( ) . DBType {
case schemas . SQLITE :
2022-08-08 17:58:11 +02:00
_ , err = x . Exec ( "INSERT INTO package_property (ref_type, ref_id, name, value) SELECT ?, p.id, ?, u.lower_name || '/' || p.lower_name FROM package p JOIN `user` u ON p.owner_id = u.id WHERE p.type = ?" ,
packages_model . PropertyTypePackage , container_module . PropertyRepository , packages_model . TypeContainer )
case schemas . MSSQL :
_ , err = x . Exec ( " INSERT INTO package_property ( ref_type , ref_id , name , value ) SELECT ? , p . id , ? , u . lower_name + '/' + p . lower_name FROM package p JOIN ` user ` u ON p . owner_id = u . id WHERE p . type = ? " ,
packages_model . PropertyTypePackage , container_module . PropertyRepository , packages_model . TypeContainer )
2022-07-30 17:52:04 +02:00
default :
2022-08-08 17:58:11 +02:00
_ , err = x . Exec ( "INSERT INTO package_property (ref_type, ref_id, name, value) SELECT ?, p.id, ?, CONCAT(u.lower_name, '/', p.lower_name) FROM package p JOIN `user` u ON p.owner_id = u.id WHERE p.type = ?" ,
packages_model . PropertyTypePackage , container_module . PropertyRepository , packages_model . TypeContainer )
2022-07-30 17:52:04 +02:00
}
2022-08-08 17:58:11 +02:00
return err
2022-07-30 17:52:04 +02:00
}