aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-05-06 01:49:38 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2019-05-06 08:49:38 +0800
commit83560bf9d0e141b1498e724d0e68d462625e4624 (patch)
tree19f4fd3142d16c80b8e866777fd6c24a5f5aba5d /models
parent6b29a6b6f20d0dc6c8b63d2b5da8e585aa7dfe51 (diff)
downloadgitea-83560bf9d0e141b1498e724d0e68d462625e4624.tar.gz
gitea-83560bf9d0e141b1498e724d0e68d462625e4624.zip
Attempt to fix #6707 (#6823) (#6854)
Diffstat (limited to 'models')
-rw-r--r--models/migrations/v78.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/models/migrations/v78.go b/models/migrations/v78.go
index b0c7bfb6e3..7ca112dbd5 100644
--- a/models/migrations/v78.go
+++ b/models/migrations/v78.go
@@ -32,7 +32,14 @@ func renameRepoIsBareToIsEmpty(x *xorm.Engine) error {
if models.DbCfg.Type == core.POSTGRES || models.DbCfg.Type == core.SQLITE {
_, err = sess.Exec("DROP INDEX IF EXISTS IDX_repository_is_bare")
} else if models.DbCfg.Type == core.MSSQL {
- _, err = sess.Exec("DROP INDEX IF EXISTS IDX_repository_is_bare ON repository")
+ _, err = sess.Exec(`DECLARE @ConstraintName VARCHAR(256)
+ DECLARE @SQL NVARCHAR(256)
+ SELECT @ConstraintName = obj.name FROM sys.columns col LEFT OUTER JOIN sys.objects obj ON obj.object_id = col.default_object_id AND obj.type = 'D' WHERE col.object_id = OBJECT_ID('repository') AND obj.name IS NOT NULL AND col.name = 'is_bare'
+ SET @SQL = N'ALTER TABLE [repository] DROP CONSTRAINT [' + @ConstraintName + N']'
+ EXEC sp_executesql @SQL`)
+ if err != nil {
+ return err
+ }
} else if models.DbCfg.Type == core.MYSQL {
indexes, err := sess.QueryString(`SHOW INDEX FROM repository WHERE KEY_NAME = 'IDX_repository_is_bare'`)
if err != nil {