Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yp05327 committed Mar 16, 2023
1 parent cffe767 commit f1e0736
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion models/migrations/v1_20/v247.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package v1_20 //nolint
import (
"code.gitea.io/gitea/modules/log"

"xorm.io/builder"
"xorm.io/xorm"
)

Expand Down Expand Up @@ -36,8 +37,18 @@ func FixIncorrectProjectType(x *xorm.Engine) error {
return err
}

sql, args, err := builder.ToSQL(
builder.And(
builder.Eq{"type": TypeOrganization},
builder.And(builder.Eq{"owner_id": builder.Select("id").From("user").Where(builder.Eq{"type": UserTypeIndividual})}),
),
)
if err != nil {
return err
}

count, err := sess.Table("project").
Where("type = ? AND owner_id IN (SELECT id FROM user WHERE type = ?)", TypeOrganization, UserTypeIndividual).
Where(sql, args...).
Update(&Project{
Type: TypeIndividual,
})
Expand Down

0 comments on commit f1e0736

Please sign in to comment.