1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 12:54:53 -05:00

Fix v220 migration to be compatible for MSSQL 2008 r2 (#20702)

This commit is contained in:
Lunny Xiao 2022-08-08 08:16:22 +08:00 committed by GitHub
parent abdebd2641
commit 5b4a84beb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,18 +12,17 @@ import (
"xorm.io/xorm/schemas" "xorm.io/xorm/schemas"
) )
func addContainerRepositoryProperty(x *xorm.Engine) error { func addContainerRepositoryProperty(x *xorm.Engine) (err error) {
switch x.Dialect().URI().DBType { switch x.Dialect().URI().DBType {
case schemas.SQLITE: case schemas.SQLITE:
_, 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) _, 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 = ?",
if err != nil { packages_model.PropertyTypePackage, container_module.PropertyRepository, packages_model.TypeContainer)
return err 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)
default: default:
_, 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) _, 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 = ?",
if err != nil { packages_model.PropertyTypePackage, container_module.PropertyRepository, packages_model.TypeContainer)
return err
}
} }
return nil return err
} }