aboutsummaryrefslogtreecommitdiff
path: root/internal/db/org.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/org.go')
-rw-r--r--internal/db/org.go20
1 files changed, 7 insertions, 13 deletions
diff --git a/internal/db/org.go b/internal/db/org.go
index 93350746..d3148745 100644
--- a/internal/db/org.go
+++ b/internal/db/org.go
@@ -235,14 +235,14 @@ func DeleteOrganization(org *User) (err error) {
// \_______ /__| \___ /|______//____ >\___ >__|
// \/ /_____/ \/ \/
-// OrgUser represents an organization-user relation.
+// OrgUser represents relations of organizations and their members.
type OrgUser struct {
- ID int64
- Uid int64 `xorm:"INDEX UNIQUE(s)"`
- OrgID int64 `xorm:"INDEX UNIQUE(s)"`
- IsPublic bool
- IsOwner bool
- NumTeams int
+ ID int64 `gorm:"primaryKey"`
+ Uid int64 `xorm:"INDEX UNIQUE(s)" gorm:"uniqueIndex:org_user_user_org_unique;index;not null"`
+ OrgID int64 `xorm:"INDEX UNIQUE(s)" gorm:"uniqueIndex:org_user_user_org_unique;index;not null"`
+ IsPublic bool `gorm:"not null;default:FALSE"`
+ IsOwner bool `gorm:"not null;default:FALSE"`
+ NumTeams int `gorm:"not null;default:0"`
}
// IsOrganizationOwner returns true if given user is in the owner team.
@@ -278,12 +278,6 @@ func GetOrgsByUserID(userID int64, showAll bool) ([]*User, error) {
return getOrgsByUserID(x.NewSession(), userID, showAll)
}
-// GetOrgsByUserIDDesc returns a list of organizations that the given user ID
-// has joined, ordered descending by the given condition.
-func GetOrgsByUserIDDesc(userID int64, desc string, showAll bool) ([]*User, error) {
- return getOrgsByUserID(x.NewSession().Desc(desc), userID, showAll)
-}
-
func getOwnedOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) {
orgs := make([]*User, 0, 10)
return orgs, sess.Where("`org_user`.uid=?", userID).And("`org_user`.is_owner=?", true).