change from db_text to nvarchar

This commit is contained in:
bergquist
2018-12-11 15:10:02 +01:00
parent dc49bebb00
commit 823bba8d98
3 changed files with 11 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ func (sl *ServerLockService) AddMigration(mg *migrator.Migrator) {
Name: "server_lock", Name: "server_lock",
Columns: []*migrator.Column{ Columns: []*migrator.Column{
{Name: "id", Type: migrator.DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, {Name: "id", Type: migrator.DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "operation_uid", Type: migrator.DB_Text}, {Name: "operation_uid", Type: migrator.DB_NVarchar, Length: 100},
{Name: "version", Type: migrator.DB_BigInt}, {Name: "version", Type: migrator.DB_BigInt},
{Name: "last_execution", Type: migrator.DB_BigInt, Nullable: false}, {Name: "last_execution", Type: migrator.DB_BigInt, Nullable: false},
}, },

View File

@@ -21,6 +21,7 @@ type ServerLockService struct {
// Init this service // Init this service
func (sl *ServerLockService) Init() error { func (sl *ServerLockService) Init() error {
sl.log = log.New("infra.lockservice")
return nil return nil
} }

View File

@@ -7,6 +7,8 @@ import (
"path" "path"
"time" "time"
"github.com/grafana/grafana/pkg/infra/serverlock"
"github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/log"
m "github.com/grafana/grafana/pkg/models" m "github.com/grafana/grafana/pkg/models"
@@ -15,8 +17,9 @@ import (
) )
type CleanUpService struct { type CleanUpService struct {
log log.Logger log log.Logger
Cfg *setting.Cfg `inject:""` Cfg *setting.Cfg `inject:""`
ServerLockService *serverlock.ServerLockService `inject:""`
} }
func init() { func init() {
@@ -38,7 +41,10 @@ func (srv *CleanUpService) Run(ctx context.Context) error {
srv.cleanUpTmpFiles() srv.cleanUpTmpFiles()
srv.deleteExpiredSnapshots() srv.deleteExpiredSnapshots()
srv.deleteExpiredDashboardVersions() srv.deleteExpiredDashboardVersions()
srv.deleteOldLoginAttempts() srv.ServerLockService.OncePerServerGroup(ctx, "delete old login attempts", time.Minute*10, func() {
srv.deleteOldLoginAttempts()
})
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err() return ctx.Err()
} }