diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-08-08 08:16:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-08 02:16:22 +0200 |
commit | 5b4a84beb4b62682328b416f309ab5b50c58eed8 (patch) | |
tree | afcbc2c3a8d8c30a4d9fa0137b4ca18d02b72a18 /models/migrations | |
parent | abdebd2641e162791144fbd57acf480b4640baa8 (diff) | |
download | gitea-5b4a84beb4b62682328b416f309ab5b50c58eed8.tar.gz gitea-5b4a84beb4b62682328b416f309ab5b50c58eed8.zip |
Fix v220 migration to be compatible for MSSQL 2008 r2 (#20702)
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/v220.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/models/migrations/v220.go b/models/migrations/v220.go index f5983582a3..8138bc5bb1 100644 --- a/models/migrations/v220.go +++ b/models/migrations/v220.go @@ -12,18 +12,17 @@ import ( "xorm.io/xorm/schemas" ) -func addContainerRepositoryProperty(x *xorm.Engine) error { +func addContainerRepositoryProperty(x *xorm.Engine) (err error) { switch x.Dialect().URI().DBType { 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) - if err != nil { - return err - } + _, 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) 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) - if err != nil { - return err - } + _, 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) } - return nil + return err } |