mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-03 00:45:22 +02:00
[CI] Fix false positive in database migration
- This also means that if one of the test fails, it will actually propagate to make and subsequently fail the test. - Remove the 'delete duplicates issue users' code, I checked this against my local development database (which contains quite bizarre cases, even some that Forgejo does not like), my local instance database and against Codeberg production and they all yielded no results to this query, so I'm removing it thus resolving the error that the delete code was not compatible with Mysql. - Sync all tables that are requires by the migration in the test. - Resolves #2206 (cherry picked from commit8e02be7e89
) (cherry picked from commit006f064416
)
This commit is contained in:
parent
3f9b7cb892
commit
e8c1bfc2e5
4 changed files with 54 additions and 34 deletions
|
@ -8,23 +8,6 @@ import (
|
|||
)
|
||||
|
||||
func AddCombinedIndexToIssueUser(x *xorm.Engine) error {
|
||||
type OldIssueUser struct {
|
||||
IssueID int64
|
||||
UID int64
|
||||
Cnt int64
|
||||
}
|
||||
|
||||
var duplicatedIssueUsers []OldIssueUser
|
||||
if err := x.SQL("select * from (select issue_id, uid, count(1) as cnt from issue_user group by issue_id, uid) a where a.cnt > 1").
|
||||
Find(&duplicatedIssueUsers); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, issueUser := range duplicatedIssueUsers {
|
||||
if _, err := x.Exec("delete from issue_user where id in (SELECT id FROM issue_user WHERE issue_id = ? and uid = ? limit ?)", issueUser.IssueID, issueUser.UID, issueUser.Cnt-1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
type IssueUser struct {
|
||||
UID int64 `xorm:"INDEX unique(uid_to_issue)"` // User ID.
|
||||
IssueID int64 `xorm:"INDEX unique(uid_to_issue)"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue