Skip to content

Commit

Permalink
Fix the v78 migration script (#5776)
Browse files Browse the repository at this point in the history
Unfortunately the last fix didn't completely fix the migration to v79 of the db
due to bug with schema locking during Sync2. This should fix this issue.

Fix #5759

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath authored and techknowlogick committed Jan 20, 2019
1 parent 71c832e commit b0fbefc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions models/migrations/v78.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func renameRepoIsBareToIsEmpty(x *xorm.Engine) error {
IsEmpty bool `xorm:"INDEX"`
}

// First remove the index
sess := x.NewSession()
defer sess.Close()
if err := sess.Begin(); err != nil {
Expand All @@ -37,6 +38,17 @@ func renameRepoIsBareToIsEmpty(x *xorm.Engine) error {
return fmt.Errorf("Drop index failed: %v", err)
}

if err = sess.Commit(); err != nil {
return err
}

// Then reset the values
sess = x.NewSession()
defer sess.Close()
if err := sess.Begin(); err != nil {
return err
}

if err := sess.Sync2(new(Repository)); err != nil {
return err
}
Expand Down

0 comments on commit b0fbefc

Please sign in to comment.