Skip to content

Commit eb25993

Browse files
committed
Add migration for PushMirror struct
1 parent 8f87595 commit eb25993

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ var migrations = []Migration{
391391
NewMigration("Improve Action table indices", improveActionTableIndices),
392392
// v217 -> v218
393393
NewMigration("Alter hook_task table TEXT fields to LONGTEXT", alterHookTaskTextFieldsToLongText),
394+
// v218 -> v219
395+
NewMigration("Add sync_on_push column to push_mirror table", addSyncOnPushColForPushMirror),
394396
}
395397

396398
// GetCurrentDBVersion returns the current db version

models/migrations/v218.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"fmt"
9+
"time"
10+
11+
"code.gitea.io/gitea/models/repo"
12+
"code.gitea.io/gitea/modules/timeutil"
13+
"xorm.io/xorm"
14+
)
15+
16+
func addSyncOnPushColForPushMirror(x *xorm.Engine) error {
17+
type PushMirror struct {
18+
ID int64 `xorm:"pk autoincr"`
19+
RepoID int64 `xorm:"INDEX"`
20+
Repo *repo.Repository `xorm:"-"`
21+
RemoteName string
22+
23+
SyncOnPush bool
24+
Interval time.Duration
25+
CreatedUnix timeutil.TimeStamp `xorm:"created"`
26+
LastUpdateUnix timeutil.TimeStamp `xorm:"INDEX last_update"`
27+
LastError string `xorm:"text"`
28+
}
29+
30+
if err := x.Sync2(new(PushMirror)); err != nil {
31+
return fmt.Errorf("sync2: %v", err)
32+
}
33+
34+
return nil
35+
}

0 commit comments

Comments
 (0)