mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
moves migrations to /sqlstore/migrations
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
package serverlock
|
||||
|
||||
import "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
|
||||
// AddMigration create database migrations for server lock
|
||||
func (sl *ServerLockService) AddMigration(mg *migrator.Migrator) {
|
||||
serverLock := migrator.Table{
|
||||
Name: "server_lock",
|
||||
Columns: []*migrator.Column{
|
||||
{Name: "id", Type: migrator.DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||
{Name: "operation_uid", Type: migrator.DB_NVarchar, Length: 100},
|
||||
{Name: "version", Type: migrator.DB_BigInt},
|
||||
{Name: "last_execution", Type: migrator.DB_BigInt, Nullable: false},
|
||||
},
|
||||
Indices: []*migrator.Index{
|
||||
{Cols: []string{"operation_uid"}, Type: migrator.UniqueIndex},
|
||||
},
|
||||
}
|
||||
|
||||
mg.AddMigration("create server_lock table", migrator.NewAddTableMigration(serverLock))
|
||||
|
||||
mg.AddMigration("add index server_lock.operation_uid", migrator.NewAddIndexMigration(serverLock, serverLock.Indices[0]))
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func (sl *ServerLockService) LockAndExecute(ctx context.Context, actionName stri
|
||||
return err
|
||||
}
|
||||
|
||||
// avoid execution if last lock happened less than `matInterval` ago
|
||||
// avoid execution if last lock happened less than `maxInterval` ago
|
||||
if rowLock.LastExecution != 0 {
|
||||
lastExeuctionTime := time.Unix(rowLock.LastExecution, 0)
|
||||
if lastExeuctionTime.Unix() > time.Now().Add(-maxInterval).Unix() {
|
||||
|
||||
Reference in New Issue
Block a user