diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-04-11 20:18:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-11 20:18:05 +0800 |
commit | 41f56ad05d12520bb90f91889fa979465d0b3d6b (patch) | |
tree | 1ec7bc62a427ec2da011e882c61f2bfe04adef37 /internal/db/models.go | |
parent | 76bb647d2437dbdea86ac1a0caf5d768ab924e18 (diff) |
login_source: migrate to GORM and add tests (#6090)
* Use GORM in all write paths
* Migrate to GORM
* Fix lint errors
* Use GORM to init table
* dbutil: make writer detect error
* Add more tests
* Rename to clearTables
* db: finish adding tests
* osutil: add tests
* Fix load source files path
Diffstat (limited to 'internal/db/models.go')
-rw-r--r-- | internal/db/models.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/db/models.go b/internal/db/models.go index 9b5b0d9a..37783a13 100644 --- a/internal/db/models.go +++ b/internal/db/models.go @@ -53,7 +53,7 @@ func init() { new(Watch), new(Star), new(Follow), new(Action), new(Issue), new(PullRequest), new(Comment), new(Attachment), new(IssueUser), new(Label), new(IssueLabel), new(Milestone), - new(Mirror), new(Release), new(LoginSource), new(Webhook), new(HookTask), + new(Mirror), new(Release), new(Webhook), new(HookTask), new(ProtectBranch), new(ProtectBranchWhitelist), new(Team), new(OrgUser), new(TeamUser), new(TeamRepo), new(Notice), new(EmailAddress)) @@ -200,7 +200,7 @@ func GetStatistic() (stats Statistic) { stats.Counter.Follow, _ = x.Count(new(Follow)) stats.Counter.Mirror, _ = x.Count(new(Mirror)) stats.Counter.Release, _ = x.Count(new(Release)) - stats.Counter.LoginSource = CountLoginSources() + stats.Counter.LoginSource = LoginSources.Count() stats.Counter.Webhook, _ = x.Count(new(Webhook)) stats.Counter.Milestone, _ = x.Count(new(Milestone)) stats.Counter.Label, _ = x.Count(new(Label)) @@ -295,13 +295,13 @@ func ImportDatabase(dirPath string, verbose bool) (err error) { tp := LoginType(com.StrTo(com.ToStr(meta["Type"])).MustInt64()) switch tp { case LoginLDAP, LoginDLDAP: - bean.Cfg = new(LDAPConfig) + bean.Config = new(LDAPConfig) case LoginSMTP: - bean.Cfg = new(SMTPConfig) + bean.Config = new(SMTPConfig) case LoginPAM: - bean.Cfg = new(PAMConfig) + bean.Config = new(PAMConfig) case LoginGitHub: - bean.Cfg = new(GitHubConfig) + bean.Config = new(GitHubConfig) default: return fmt.Errorf("unrecognized login source type:: %v", tp) } |