From 8ffc0653fbcf94294d46a6c9855abadb0c486084 Mon Sep 17 00:00:00 2001 From: Ezra Buehler Date: Fri, 20 Oct 2023 16:24:55 +0200 Subject: [PATCH] Add missing DB migration for Host.Name Commit 44559f0 ("fix: increase size of name fields") changed the size of the `Host.Name` DB field but did not add a migration. --- pkg/bastion/dbinit.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/bastion/dbinit.go b/pkg/bastion/dbinit.go index c47468d..5204ec9 100644 --- a/pkg/bastion/dbinit.go +++ b/pkg/bastion/dbinit.go @@ -536,6 +536,28 @@ func DBInit(db *gorm.DB) error { return tx.AutoMigrate(&ACL{}) }, Rollback: func(tx *gorm.DB) error { return fmt.Errorf("not implemented") }, + }, { + ID: "33", + Migrate: func(tx *gorm.DB) error { + type Host struct { + gorm.Model + Name string `gorm:"index:uix_hosts_name,unique;type:varchar(255)" valid:"required,length(1|255)"` + Addr string + User string + Password string + URL string + SSHKey *dbmodels.SSHKey `gorm:"ForeignKey:SSHKeyID"` + SSHKeyID uint `gorm:"index"` + HostKey []byte `sql:"size:10000"` + Groups []*dbmodels.HostGroup `gorm:"many2many:host_host_groups;"` + Comment string + Hop *dbmodels.Host + Logging string + HopID uint + } + return tx.AutoMigrate(&Host{}) + }, + Rollback: func(tx *gorm.DB) error { return fmt.Errorf("not implemented") }, }, }) if err := m.Migrate(); err != nil {