diff --git a/pkg/db/migrations/202401151014_add_server_instances.go b/pkg/db/migrations/202401151014_add_server_instances.go index 2a733721..281481a4 100644 --- a/pkg/db/migrations/202401151014_add_server_instances.go +++ b/pkg/db/migrations/202401151014_add_server_instances.go @@ -1,8 +1,6 @@ package migrations import ( - "time" - "gorm.io/gorm" "github.com/go-gormigrate/gormigrate/v2" @@ -11,8 +9,6 @@ import ( func addServerInstances() *gormigrate.Migration { type ServerInstance struct { Model - LastHeartbeat time.Time - Ready bool `gorm:"default:false"` } return &gormigrate.Migration{ diff --git a/pkg/db/migrations/202412171429_add_last_heartbeat_and_ready_column_in_server_instances_tables.go b/pkg/db/migrations/202412171429_add_last_heartbeat_and_ready_column_in_server_instances_tables.go new file mode 100644 index 00000000..6565e5a0 --- /dev/null +++ b/pkg/db/migrations/202412171429_add_last_heartbeat_and_ready_column_in_server_instances_tables.go @@ -0,0 +1,30 @@ +package migrations + +import ( + "time" + + "gorm.io/gorm" + + "github.com/go-gormigrate/gormigrate/v2" +) + +func addLastHeartBeatAndReadyColumnInServerInstancesTable() *gormigrate.Migration { + type ServerInstance struct { + LastHeartbeat time.Time + Ready bool `gorm:"default:false"` + } + + return &gormigrate.Migration{ + ID: "202412171429", + Migrate: func(tx *gorm.DB) error { + return tx.AutoMigrate(&ServerInstance{}) + }, + Rollback: func(tx *gorm.DB) error { + err := tx.Migrator().DropColumn(&ServerInstance{}, "ready") + if err != nil { + return err + } + return tx.Migrator().DropColumn(&ServerInstance{}, "last_heartbeat") + }, + } +} diff --git a/pkg/db/migrations/migration_structs.go b/pkg/db/migrations/migration_structs.go index 2a5e652b..2707961e 100755 --- a/pkg/db/migrations/migration_structs.go +++ b/pkg/db/migrations/migration_structs.go @@ -34,6 +34,7 @@ var MigrationList = []*gormigrate.Migration{ addServerInstances(), addStatusEvents(), addEventInstances(), + addLastHeartBeatAndReadyColumnInServerInstancesTable(), } // Model represents the base model struct. All entities will have this struct embedded.