28 lines
739 B
Go
28 lines
739 B
Go
package version_local
|
|
|
|
import (
|
|
"runtime"
|
|
|
|
goautomigrations "go-admin/app/goauto/migrations"
|
|
"go-admin/cmd/migrate/migration"
|
|
common "go-admin/common/models"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// This version adds the device capability snapshot used to keep old Agents on
|
|
// v1 tasks while scheduling v2 rules only to compatible Agent versions.
|
|
func init() {
|
|
_, fileName, _, _ := runtime.Caller(0)
|
|
migration.Migrate.SetVersion(migration.GetFilename(fileName), migrateDeviceCapabilities)
|
|
}
|
|
|
|
func migrateDeviceCapabilities(db *gorm.DB, version string) error {
|
|
return db.Transaction(func(tx *gorm.DB) error {
|
|
if err := goautomigrations.Migrate(tx); err != nil {
|
|
return err
|
|
}
|
|
return tx.Create(&common.Migration{Version: version}).Error
|
|
})
|
|
}
|