Skip to content

Commit

Permalink
Add unique constraint back into issue_index (#16938)
Browse files Browse the repository at this point in the history
There is a flaw in #16820 where it was missed that although xorm will
not add a primary key to a table during syncing, it will remove an
unique constraint.

Users upgrading from 1.15.0 to 1.15.1 will therefore lose the unique
constraint that makes this table work unless they run `gitea doctor
recreate-table issue_index`.  Postgres helpfully warns about this
situation but MySQL does not.

Main/1.16-dev is not affected by this issue as there is a migration that
does the above recreation by default. Users moving directly to 1.15.1
from 1.14.x or lower are also not affected.

Whilst we could force all users who ran 1.15.0 to do the above
recreate-table call, this PR proposes an alternative: Just add the
unique constraint back in for 1.15.x. This won't have any long term
effects - just some wasted space for the unnecessary index.

Fix #16936

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath authored Sep 3, 2021
1 parent 3365611 commit 6f261fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion models/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// ResourceIndex represents a resource index which could be used as issue/release and others
// We can create different tables i.e. issue_index, release_index and etc.
type ResourceIndex struct {
GroupID int64 `xorm:"pk"`
GroupID int64 `xorm:"pk unique"`
MaxIndex int64 `xorm:"index"`
}

Expand Down

0 comments on commit 6f261fd

Please sign in to comment.