-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Do not store user projects as organization projects #23353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lunny
merged 29 commits into
go-gitea:main
from
yp05327:fix-incorrect-project-type-in-user-newprojectpost
Mar 17, 2023
Merged
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
f5992a7
fix incorrect project type
yp05327 de62b05
add db migration
yp05327 293a68e
fix project list page
yp05327 5bcc68c
(error preview)
yp05327 b1a471a
fix
yp05327 581bc03
fix lint
yp05327 0241dcb
Update models/migrations/v1_20/v245.go
yp05327 ed4214b
add session, fixme
yp05327 920c565
update
yp05327 a4c81e0
Merge branch 'main' into fix-incorrect-project-type-in-user-newprojec…
yp05327 4b26d6c
Update models/migrations/v1_20/v246.go
yp05327 8f5eb33
Update models/migrations/v1_20/v246.go
yp05327 075da0e
fix lint
yp05327 3bcc288
add TypeRepository as valid project type
yp05327 72e00b0
test: use = instead of IN
yp05327 41671bb
Revert "test: use = instead of IN"
yp05327 3d86625
update
yp05327 daf20f2
Revert "update"
yp05327 d95d35b
change 246 to 247
yp05327 ece905b
Merge branch 'main' into fix-incorrect-project-type-in-user-newprojec…
yp05327 cffe767
fix lint
yp05327 f1e0736
update
yp05327 2b90ac8
Revert "update"
yp05327 64e4395
update
yp05327 57e87f2
Merge branch 'main' into fix-incorrect-project-type-in-user-newprojec…
6543 795a73a
Merge branch 'main' into fix-incorrect-project-type-in-user-newprojec…
lunny 55f2c0a
Merge branch 'main' into fix-incorrect-project-type-in-user-newprojec…
lunny 474dfe4
Merge branch 'main' into fix-incorrect-project-type-in-user-newprojec…
lunny 35e4862
Merge branch 'main' into fix-incorrect-project-type-in-user-newprojec…
lunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package v1_20 //nolint | ||
|
||
import ( | ||
"fmt" | ||
|
||
"code.gitea.io/gitea/modules/log" | ||
"xorm.io/xorm" | ||
) | ||
|
||
// FixIncorrectProjectType: set individual project's type from 3(TypeOrganization) to 1(TypeIndividual) | ||
func FixIncorrectProjectType(x *xorm.Engine) error { | ||
type User struct { | ||
ID int64 `xorm:"pk autoincr"` | ||
Type int | ||
} | ||
|
||
const ( | ||
UserTypeIndividual int = 0 | ||
|
||
TypeIndividual uint8 = 1 | ||
TypeOrganization uint8 = 3 | ||
) | ||
|
||
type Project struct { | ||
OwnerID int64 `xorm:"INDEX"` | ||
Type uint8 | ||
Owner *User `xorm:"extends"` | ||
} | ||
|
||
ps := make([]Project, 0, 10) | ||
yp05327 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
count, err := x.Table("project"). | ||
//err := x.Table("project"). | ||
Join("INNER", "user", "user.id = project.owner_id"). | ||
Where("project.type = ? AND user.type = ?", TypeOrganization, UserTypeIndividual). | ||
//Find(&ps) | ||
Update(&Project{ | ||
Type: TypeIndividual, | ||
}) | ||
|
||
if err == nil { | ||
log.Debug("Updated %d projects with owner IS UserTypeIndividual", count) | ||
yp05327 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for _, p := range ps { | ||
fmt.Println(p) | ||
fmt.Println(p.Owner) | ||
} | ||
yp05327 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return err | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.