From f48c0f2910ec81f480b5af390b9f38b2bc95558f Mon Sep 17 00:00:00 2001 From: wubijie Date: Wed, 6 Nov 2024 09:34:46 +0800 Subject: [PATCH] add sshd file struct --- configmanage/server/internal/sshd.go | 27 +++++++++++++++++++ configmanage/server/service/configinstance.go | 4 +++ 2 files changed, 31 insertions(+) create mode 100644 configmanage/server/internal/sshd.go diff --git a/configmanage/server/internal/sshd.go b/configmanage/server/internal/sshd.go new file mode 100644 index 00000000..ccfc1f56 --- /dev/null +++ b/configmanage/server/internal/sshd.go @@ -0,0 +1,27 @@ +package internal + +import ( + "encoding/json" + "time" + + "openeuler.org/PilotGo/configmanage-plugin/db" +) + +type SSHDFile struct { + ID int `gorm:"unique;autoIncrement:true"` + UUID string `gorm:"primary_key;type:varchar(50)" json:"uuid"` + ConfigInfo ConfigInfo `gorm:"Foreignkey:ConfigInfoUUID"` + ConfigInfoUUID string + Path string `json:"path"` + Name string `json:"name"` + Content json.RawMessage `gorm:"type:json" json:"content"` + Version string `gorm:"type:varchar(50)" json:"version"` + IsActive bool `json:"isactive"` + IsFromHost bool `gorm:"default:false" json:"isfromhost"` + Hostuuid string `gorm:"type:varchar(50)" json:"hostuuid"` + CreatedAt time.Time +} + +func (sdf *SSHDFile) Add() error { + return db.MySQL().Save(&sdf).Error +} diff --git a/configmanage/server/service/configinstance.go b/configmanage/server/service/configinstance.go index 771afbc1..e3033d9e 100644 --- a/configmanage/server/service/configinstance.go +++ b/configmanage/server/service/configinstance.go @@ -42,6 +42,10 @@ func Init() error { if err != nil { return err } + err = db.MySQL().Set("gorm:table_options", "ENGINE=InnoDB CHARACTER SET utf8mb4").AutoMigrate(&internal.SSHDFile{}) + if err != nil { + return err + } return nil } -- Gitee