Skip to content
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

feat(model): support postgres schema. #3348

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions custom/conf/app.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ SQLITE_TIMEOUT = 500
ITERATE_BUFFER_SIZE = 50
; Show the database generated SQL
LOG_SQL = true
; For "postgres" only, default is public
SCHEMA = public

[indexer]
ISSUE_INDEXER_PATH = indexers/issues.bleve
Expand Down
2 changes: 1 addition & 1 deletion models/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Attachment struct {
// IncreaseDownloadCount is update download count + 1
func (a *Attachment) IncreaseDownloadCount() error {
// Update download count.
if _, err := x.Exec("UPDATE `attachment` SET download_count=download_count+1 WHERE id=?", a.ID); err != nil {
if _, err := x.Exec("UPDATE "+x.TableName("attachment", isPGEngine())+" SET download_count=download_count+1 WHERE id=?", a.ID); err != nil {
return fmt.Errorf("increase attachment count: %v", err)
}

Expand Down
6 changes: 3 additions & 3 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,9 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
}

if opts.IsPull {
_, err = e.Exec("UPDATE `repository` SET num_pulls = num_pulls + 1 WHERE id = ?", opts.Issue.RepoID)
_, err = e.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_pulls = num_pulls + 1 WHERE id = ?", opts.Issue.RepoID)
} else {
_, err = e.Exec("UPDATE `repository` SET num_issues = num_issues + 1 WHERE id = ?", opts.Issue.RepoID)
_, err = e.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_issues = num_issues + 1 WHERE id = ?", opts.Issue.RepoID)
}
if err != nil {
return err
Expand Down Expand Up @@ -1198,7 +1198,7 @@ func getParticipantsByIssueID(e Engine, issueID int64) ([]*User, error) {
And("`comment`.type = ?", CommentTypeComment).
And("`user`.is_active = ?", true).
And("`user`.prohibit_login = ?", false).
Join("INNER", "user", "`user`.id = `comment`.poster_id").
Join("INNER", &User{}, "`user`.id = `comment`.poster_id").
Distinct("poster_id").
Find(&userIDs); err != nil {
return nil, fmt.Errorf("get poster IDs: %v", err)
Expand Down
12 changes: 6 additions & 6 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
case CommentTypeComment:
act.OpType = ActionCommentIssue

if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil {
if _, err = e.Exec("UPDATE "+x.TableName("issue", isPGEngine())+" SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil {
return nil, err
}

Expand Down Expand Up @@ -389,9 +389,9 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
}

if opts.Issue.IsPull {
_, err = e.Exec("UPDATE `repository` SET num_closed_pulls=num_closed_pulls-1 WHERE id=?", opts.Repo.ID)
_, err = e.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_closed_pulls=num_closed_pulls-1 WHERE id=?", opts.Repo.ID)
} else {
_, err = e.Exec("UPDATE `repository` SET num_closed_issues=num_closed_issues-1 WHERE id=?", opts.Repo.ID)
_, err = e.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_closed_issues=num_closed_issues-1 WHERE id=?", opts.Repo.ID)
}
if err != nil {
return nil, err
Expand All @@ -404,9 +404,9 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
}

if opts.Issue.IsPull {
_, err = e.Exec("UPDATE `repository` SET num_closed_pulls=num_closed_pulls+1 WHERE id=?", opts.Repo.ID)
_, err = e.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_closed_pulls=num_closed_pulls+1 WHERE id=?", opts.Repo.ID)
} else {
_, err = e.Exec("UPDATE `repository` SET num_closed_issues=num_closed_issues+1 WHERE id=?", opts.Repo.ID)
_, err = e.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_closed_issues=num_closed_issues+1 WHERE id=?", opts.Repo.ID)
}
if err != nil {
return nil, err
Expand Down Expand Up @@ -720,7 +720,7 @@ func DeleteComment(comment *Comment) error {
}

if comment.Type == CommentTypeComment {
if _, err := sess.Exec("UPDATE `issue` SET num_comments = num_comments - 1 WHERE id = ?", comment.IssueID); err != nil {
if _, err := sess.Exec("UPDATE "+x.TableName("issue", isPGEngine())+" SET num_comments = num_comments - 1 WHERE id = ?", comment.IssueID); err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion models/issue_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (issues IssueList) loadAssignees(e Engine) error {

var assignees = make(map[int64][]*User, len(issues))
rows, err := e.Table("issue_assignees").
Join("INNER", "user", "`user`.id = `issue_assignees`.assignee_id").
Join("INNER", &User{}, "`user`.id = `issue_assignees`.assignee_id").
In("`issue_assignees`.issue_id", issues.getIssueIDs()).
Rows(new(AssigneeIssue))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions models/issue_milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func NewMilestone(m *Milestone) (err error) {
return err
}

if _, err = sess.Exec("UPDATE `repository` SET num_milestones = num_milestones + 1 WHERE id = ?", m.RepoID); err != nil {
if _, err = sess.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_milestones = num_milestones + 1 WHERE id = ?", m.RepoID); err != nil {
return err
}
return sess.Commit()
Expand Down Expand Up @@ -401,7 +401,7 @@ func DeleteMilestoneByRepoID(repoID, id int64) error {
return err
}

if _, err = sess.Exec("UPDATE `issue` SET milestone_id = 0 WHERE milestone_id = ?", m.ID); err != nil {
if _, err = sess.Exec("UPDATE "+x.TableName("issue", isPGEngine())+" SET milestone_id = 0 WHERE milestone_id = ?", m.ID); err != nil {
return err
}
return sess.Commit()
Expand Down
2 changes: 1 addition & 1 deletion models/issue_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func updateIssueAssignee(e *xorm.Session, issue *Issue, assigneeID int64) (remov

// UpdateIssueUserByRead updates issue-user relation for reading.
func UpdateIssueUserByRead(uid, issueID int64) error {
_, err := x.Exec("UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=?", true, uid, issueID)
_, err := x.Exec("UPDATE "+x.TableName("issue_user", isPGEngine())+" SET is_read=? WHERE uid=? AND issue_id=?", true, uid, issueID)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion models/issue_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func getIssueWatchers(e Engine, issueID int64) (watches []*IssueWatch, err error
Where("`issue_watch`.issue_id = ?", issueID).
And("`user`.is_active = ?", true).
And("`user`.prohibit_login = ?", false).
Join("INNER", "user", "`user`.id = `issue_watch`.user_id").
Join("INNER", &User{}, "`user`.id = `issue_watch`.user_id").
Find(&watches)
return
}
44 changes: 42 additions & 2 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ var (

// DbCfg holds the database settings
DbCfg struct {
Type, Host, Name, User, Passwd, Path, SSLMode string
Timeout int
Type, Host, Name, User, Passwd, Path, SSLMode, Schema string
Timeout int
}

// EnableSQLite3 use SQLite3
Expand Down Expand Up @@ -147,6 +147,7 @@ func LoadConfigs() {
DbCfg.Host = sec.Key("HOST").String()
DbCfg.Name = sec.Key("NAME").String()
DbCfg.User = sec.Key("USER").String()
DbCfg.Schema = sec.Key("SCHEMA").MustString("public")
if len(DbCfg.Passwd) == 0 {
DbCfg.Passwd = sec.Key("PASSWD").String()
}
Expand Down Expand Up @@ -275,6 +276,29 @@ func SetEngine() (err error) {
return nil
}

// SetSchema for setting default postgres schema.
func SetSchema() (err error) {
if !setting.UsePostgreSQL {
return nil
}

row, err := x.Exec(`SELECT schema_name FROM information_schema.schemata WHERE schema_name = '` + DbCfg.Schema + `';`)
if err != nil {
return err
}

affects, err := row.RowsAffected()
if affects == 0 {
if _, err = x.Exec(`CREATE SCHEMA "` + DbCfg.Schema + `"`); err != nil {
return err
}
}

x.SetSchema(DbCfg.Schema)

return nil
}

// NewEngine initializes a new xorm.Engine
func NewEngine(migrateFunc func(*xorm.Engine) error) (err error) {
if err = SetEngine(); err != nil {
Expand All @@ -285,6 +309,10 @@ func NewEngine(migrateFunc func(*xorm.Engine) error) (err error) {
return err
}

if err = SetSchema(); err != nil {
return err
}

if err = migrateFunc(x); err != nil {
return fmt.Errorf("migrate: %v", err)
}
Expand Down Expand Up @@ -353,3 +381,15 @@ func DumpDatabase(filePath string, dbType string) error {
}
return x.DumpTablesToFile(tbs, filePath)
}

func schemaQuery(sql string) string {
if !setting.UsePostgreSQL {
return sql
}

return "SET SEARCH_PATH TO " + DbCfg.Schema + ", pg_catalog;" + sql
}

func isPGEngine() bool {
return setting.UsePostgreSQL
}
8 changes: 4 additions & 4 deletions models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error) {
func GetOrgUsersByUserID(uid int64, all bool) ([]*OrgUser, error) {
ous := make([]*OrgUser, 0, 10)
sess := x.
Join("LEFT", "user", "`org_user`.org_id=`user`.id").
Join("LEFT", &User{}, "`org_user`.org_id=`user`.id").
Where("`org_user`.uid=?", uid)
if !all {
// Only show public organizations
Expand Down Expand Up @@ -428,7 +428,7 @@ func AddOrgUser(orgID, uid int64) error {
if _, err := sess.Insert(ou); err != nil {
sess.Rollback()
return err
} else if _, err = sess.Exec("UPDATE `user` SET num_members = num_members + 1 WHERE id = ?", orgID); err != nil {
} else if _, err = sess.Exec("UPDATE "+x.TableName("user", isPGEngine())+" SET num_members = num_members + 1 WHERE id = ?", orgID); err != nil {
sess.Rollback()
return err
}
Expand Down Expand Up @@ -474,7 +474,7 @@ func removeOrgUser(sess *xorm.Session, orgID, userID int64) error {

if _, err := sess.ID(ou.ID).Delete(ou); err != nil {
return err
} else if _, err = sess.Exec("UPDATE `user` SET num_members=num_members-1 WHERE id=?", orgID); err != nil {
} else if _, err = sess.Exec("UPDATE "+x.TableName("user", isPGEngine())+" SET num_members=num_members-1 WHERE id=?", orgID); err != nil {
return err
}

Expand Down Expand Up @@ -560,7 +560,7 @@ func (org *User) getUserTeams(e Engine, userID int64, cols ...string) ([]*Team,
return teams, e.
Where("`team_user`.org_id = ?", org.ID).
Join("INNER", "team_user", "`team_user`.team_id = team.id").
Join("INNER", "user", "`user`.id=team_user.uid").
Join("INNER", &User{}, "`user`.id=team_user.uid").
And("`team_user`.uid = ?", userID).
Asc("`user`.name").
Cols(cols...).
Expand Down
44 changes: 22 additions & 22 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1569,9 +1569,9 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
}

// Update repository count.
if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos+1 WHERE id=?", newOwner.ID); err != nil {
if _, err = sess.Exec("UPDATE "+x.TableName("user", isPGEngine())+" SET num_repos=num_repos+1 WHERE id=?", newOwner.ID); err != nil {
return fmt.Errorf("increase new owner repository count: %v", err)
} else if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos-1 WHERE id=?", owner.ID); err != nil {
} else if _, err = sess.Exec("UPDATE "+x.TableName("user", isPGEngine())+" SET num_repos=num_repos-1 WHERE id=?", owner.ID); err != nil {
return fmt.Errorf("decrease old owner repository count: %v", err)
}

Expand Down Expand Up @@ -1871,12 +1871,12 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
}

if repo.IsFork {
if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks-1 WHERE id=?", repo.ForkID); err != nil {
if _, err = sess.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_forks=num_forks-1 WHERE id=?", repo.ForkID); err != nil {
return fmt.Errorf("decrease fork count: %v", err)
}
}

if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos-1 WHERE id=?", uid); err != nil {
if _, err = sess.Exec("UPDATE "+x.TableName("user", isPGEngine())+" SET num_repos=num_repos-1 WHERE id=?", uid); err != nil {
return err
}

Expand Down Expand Up @@ -1919,7 +1919,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
}

if repo.NumForks > 0 {
if _, err = sess.Exec("UPDATE `repository` SET fork_id=0,is_fork=? WHERE fork_id=?", false, repo.ID); err != nil {
if _, err = sess.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET fork_id=0,is_fork=? WHERE fork_id=?", false, repo.ID); err != nil {
log.Error(4, "reset 'fork_id' and 'is_fork': %v", err)
}
}
Expand Down Expand Up @@ -1949,7 +1949,7 @@ func GetRepositoryByOwnerAndName(ownerName, repoName string) (*Repository, error
var repo Repository
has, err := x.Select("repository.*").
Join("INNER", "user", "`user`.id = repository.owner_id").
Where("repository.lower_name = ?", strings.ToLower(repoName)).
Where("`repository`.lower_name = ?", strings.ToLower(repoName)).
And("`user`.lower_name = ?", strings.ToLower(ownerName)).
Get(&repo)
if err != nil {
Expand Down Expand Up @@ -2267,7 +2267,7 @@ type repoChecker struct {
}

func repoStatsCheck(checker *repoChecker) {
results, err := x.Query(checker.querySQL)
results, err := x.Query(schemaQuery(checker.querySQL))
if err != nil {
log.Error(4, "Select %s: %v", checker.desc, err)
return
Expand All @@ -2294,32 +2294,32 @@ func CheckRepoStats() {
checkers := []*repoChecker{
// Repository.NumWatches
{
"SELECT repo.id FROM `repository` repo WHERE repo.num_watches!=(SELECT COUNT(*) FROM `watch` WHERE repo_id=repo.id)",
"UPDATE `repository` SET num_watches=(SELECT COUNT(*) FROM `watch` WHERE repo_id=?) WHERE id=?",
"SELECT repo.id FROM " + x.TableName("repository", isPGEngine()) + " repo WHERE repo.num_watches!=(SELECT COUNT(*) FROM `watch` WHERE repo_id=repo.id)",
"UPDATE " + x.TableName("repository", isPGEngine()) + " SET num_watches=(SELECT COUNT(*) FROM `watch` WHERE repo_id=?) WHERE id=?",
"repository count 'num_watches'",
},
// Repository.NumStars
{
"SELECT repo.id FROM `repository` repo WHERE repo.num_stars!=(SELECT COUNT(*) FROM `star` WHERE repo_id=repo.id)",
"UPDATE `repository` SET num_stars=(SELECT COUNT(*) FROM `star` WHERE repo_id=?) WHERE id=?",
"SELECT repo.id FROM " + x.TableName("repository", isPGEngine()) + " repo WHERE repo.num_stars!=(SELECT COUNT(*) FROM `star` WHERE repo_id=repo.id)",
"UPDATE " + x.TableName("repository", isPGEngine()) + " SET num_stars=(SELECT COUNT(*) FROM `star` WHERE repo_id=?) WHERE id=?",
"repository count 'num_stars'",
},
// Label.NumIssues
{
"SELECT label.id FROM `label` WHERE label.num_issues!=(SELECT COUNT(*) FROM `issue_label` WHERE label_id=label.id)",
"UPDATE `label` SET num_issues=(SELECT COUNT(*) FROM `issue_label` WHERE label_id=?) WHERE id=?",
"SELECT label.id FROM " + x.TableName("label", isPGEngine()) + " WHERE label.num_issues!=(SELECT COUNT(*) FROM `issue_label` WHERE label_id=label.id)",
"UPDATE " + x.TableName("label", isPGEngine()) + " SET num_issues=(SELECT COUNT(*) FROM `issue_label` WHERE label_id=?) WHERE id=?",
"label count 'num_issues'",
},
// User.NumRepos
{
"SELECT `user`.id FROM `user` WHERE `user`.num_repos!=(SELECT COUNT(*) FROM `repository` WHERE owner_id=`user`.id)",
"UPDATE `user` SET num_repos=(SELECT COUNT(*) FROM `repository` WHERE owner_id=?) WHERE id=?",
"SELECT user.id FROM " + x.TableName("user", isPGEngine()) + " WHERE user.num_repos!=(SELECT COUNT(*) FROM " + x.TableName("repository", isPGEngine()) + " WHERE owner_id=user.id)",
"UPDATE " + x.TableName("user", isPGEngine()) + " SET num_repos=(SELECT COUNT(*) FROM " + x.TableName("repository", isPGEngine()) + " WHERE owner_id=?) WHERE id=?",
"user count 'num_repos'",
},
// Issue.NumComments
{
"SELECT `issue`.id FROM `issue` WHERE `issue`.num_comments!=(SELECT COUNT(*) FROM `comment` WHERE issue_id=`issue`.id AND type=0)",
"UPDATE `issue` SET num_comments=(SELECT COUNT(*) FROM `comment` WHERE issue_id=? AND type=0) WHERE id=?",
"SELECT `issue`.id FROM " + x.TableName("issue", isPGEngine()) + " WHERE `issue`.num_comments!=(SELECT COUNT(*) FROM " + x.TableName("comment", isPGEngine()) + " WHERE issue_id=`issue`.id AND type=0)",
"UPDATE " + x.TableName("issue", isPGEngine()) + " SET num_comments=(SELECT COUNT(*) FROM " + x.TableName("comment", isPGEngine()) + " WHERE issue_id=? AND type=0) WHERE id=?",
"issue count 'num_comments'",
},
}
Expand All @@ -2329,14 +2329,14 @@ func CheckRepoStats() {

// ***** START: Repository.NumClosedIssues *****
desc := "repository count 'num_closed_issues'"
results, err := x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_closed_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", true, false)
results, err := x.Query(schemaQuery("SELECT repo.id FROM "+x.TableName("repository", isPGEngine())+" repo WHERE repo.num_closed_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)"), true, false)
if err != nil {
log.Error(4, "Select %s: %v", desc, err)
} else {
for _, result := range results {
id := com.StrTo(result["id"]).MustInt64()
log.Trace("Updating %s: %d", desc, id)
_, err = x.Exec("UPDATE `repository` SET num_closed_issues=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=? AND is_pull=?) WHERE id=?", id, true, false, id)
_, err = x.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_closed_issues=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=? AND is_pull=?) WHERE id=?", id, true, false, id)
if err != nil {
log.Error(4, "Update %s[%d]: %v", desc, id, err)
}
Expand All @@ -2346,7 +2346,7 @@ func CheckRepoStats() {

// FIXME: use checker when stop supporting old fork repo format.
// ***** START: Repository.NumForks *****
results, err = x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_forks!=(SELECT COUNT(*) FROM `repository` WHERE fork_id=repo.id)")
results, err = x.Query(schemaQuery("SELECT repo.id FROM " + x.TableName("repository", isPGEngine()) + " repo WHERE repo.num_forks!=(SELECT COUNT(*) FROM " + x.TableName("repository", isPGEngine()) + " WHERE fork_id=repo.id)"))
if err != nil {
log.Error(4, "Select repository count 'num_forks': %v", err)
} else {
Expand All @@ -2360,7 +2360,7 @@ func CheckRepoStats() {
continue
}

rawResult, err := x.Query("SELECT COUNT(*) FROM `repository` WHERE fork_id=?", repo.ID)
rawResult, err := x.Query(schemaQuery("SELECT COUNT(*) FROM "+x.TableName("repository", isPGEngine())+" WHERE fork_id=?"), repo.ID)
if err != nil {
log.Error(4, "Select count of forks[%d]: %v", repo.ID, err)
continue
Expand Down Expand Up @@ -2427,7 +2427,7 @@ func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *R
return nil, err
}

if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks+1 WHERE id=?", oldRepo.ID); err != nil {
if _, err = sess.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET num_forks=num_forks+1 WHERE id=?", oldRepo.ID); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion models/repo_collaboration.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode
Cols("mode").
Update(collaboration); err != nil {
return fmt.Errorf("update collaboration: %v", err)
} else if _, err = sess.Exec("UPDATE access SET mode = ? WHERE user_id = ? AND repo_id = ?", mode, uid, repo.ID); err != nil {
} else if _, err = sess.Exec("UPDATE "+x.TableName("access", isPGEngine())+" SET mode = ? WHERE user_id = ? AND repo_id = ?", mode, uid, repo.ID); err != nil {
return fmt.Errorf("update access table: %v", err)
}

Expand Down
2 changes: 1 addition & 1 deletion models/repo_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func SyncMirrors() {
continue
}

if _, err = sess.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", commitDate.Unix(), m.RepoID); err != nil {
if _, err = sess.Exec("UPDATE "+x.TableName("repository", isPGEngine())+" SET updated_unix = ? WHERE id = ?", commitDate.Unix(), m.RepoID); err != nil {
log.Error(2, "Update repository 'updated_unix' [%s]: %v", m.RepoID, err)
continue
}
Expand Down
Loading