Skip to content

Commit 83560bf

Browse files
zeripathlunny
authored andcommitted
Attempt to fix #6707 (#6823) (#6854)
1 parent 6b29a6b commit 83560bf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: models/migrations/v78.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ func renameRepoIsBareToIsEmpty(x *xorm.Engine) error {
3232
if models.DbCfg.Type == core.POSTGRES || models.DbCfg.Type == core.SQLITE {
3333
_, err = sess.Exec("DROP INDEX IF EXISTS IDX_repository_is_bare")
3434
} else if models.DbCfg.Type == core.MSSQL {
35-
_, err = sess.Exec("DROP INDEX IF EXISTS IDX_repository_is_bare ON repository")
35+
_, err = sess.Exec(`DECLARE @ConstraintName VARCHAR(256)
36+
DECLARE @SQL NVARCHAR(256)
37+
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'
38+
SET @SQL = N'ALTER TABLE [repository] DROP CONSTRAINT [' + @ConstraintName + N']'
39+
EXEC sp_executesql @SQL`)
40+
if err != nil {
41+
return err
42+
}
3643
} else if models.DbCfg.Type == core.MYSQL {
3744
indexes, err := sess.QueryString(`SHOW INDEX FROM repository WHERE KEY_NAME = 'IDX_repository_is_bare'`)
3845
if err != nil {

0 commit comments

Comments
 (0)