2022-08-16 23:30:23 +08:00
|
|
|
package migrations
|
|
|
|
|
|
|
|
import (
|
2022-09-09 17:17:02 +08:00
|
|
|
"time"
|
|
|
|
|
2022-08-16 23:30:23 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/app/model"
|
|
|
|
|
|
|
|
"github.com/go-gormigrate/gormigrate/v2"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
var AddTableOperationLog = &gormigrate.Migration{
|
|
|
|
ID: "20200809-add-table-operation-log",
|
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
return tx.AutoMigrate(&model.OperationLog{})
|
|
|
|
},
|
|
|
|
}
|
2022-08-18 18:54:21 +08:00
|
|
|
|
|
|
|
var AddTableHost = &gormigrate.Migration{
|
|
|
|
ID: "20200818-add-table-host",
|
|
|
|
Migrate: func(tx *gorm.DB) error {
|
2022-08-31 23:16:10 +08:00
|
|
|
if err := tx.AutoMigrate(&model.Host{}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.AutoMigrate(&model.Group{}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.AutoMigrate(&model.Command{}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-09-01 16:48:43 +08:00
|
|
|
group := model.Group{
|
|
|
|
Name: "default", Type: "host",
|
|
|
|
}
|
|
|
|
if err := tx.Create(&group).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-08-31 23:16:10 +08:00
|
|
|
return nil
|
2022-08-18 18:54:21 +08:00
|
|
|
},
|
|
|
|
}
|
2022-09-08 11:39:14 +08:00
|
|
|
|
2022-09-15 10:44:43 +08:00
|
|
|
var AddTableMonitor = &gormigrate.Migration{
|
2022-09-08 11:39:14 +08:00
|
|
|
ID: "20200905-add-table-monitor",
|
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
return tx.AutoMigrate(&model.MonitorBase{}, &model.MonitorIO{}, &model.MonitorNetwork{})
|
|
|
|
},
|
|
|
|
}
|
2022-09-15 10:44:43 +08:00
|
|
|
|
|
|
|
var AddTableSetting = &gormigrate.Migration{
|
|
|
|
ID: "20200908-add-table-setting",
|
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
if err := tx.AutoMigrate(&model.Setting{}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "UserName", Value: "admin"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "Password", Value: "5WYEZ4XcitdomVvAyimt9WwJwBJJSbTTHncZoqyOraQ="}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "Email", Value: ""}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Create(&model.Setting{Key: "PanelName", Value: "1Panel"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-09-13 18:45:03 +08:00
|
|
|
if err := tx.Create(&model.Setting{Key: "Language", Value: "zh"}).Error; err != nil {
|
2022-09-15 10:44:43 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "Theme", Value: "auto"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Create(&model.Setting{Key: "SessionTimeout", Value: "86400"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-09-09 17:17:02 +08:00
|
|
|
if err := tx.Create(&model.Setting{Key: "LocalTime", Value: ""}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-09-15 10:44:43 +08:00
|
|
|
|
|
|
|
if err := tx.Create(&model.Setting{Key: "ServerPort", Value: "4004"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-09-15 17:15:03 +08:00
|
|
|
if err := tx.Create(&model.Setting{Key: "SecurityEntrance", Value: "89dc6ae8"}).Error; err != nil {
|
2022-09-15 10:44:43 +08:00
|
|
|
return err
|
|
|
|
}
|
2022-09-09 17:17:02 +08:00
|
|
|
if err := tx.Create(&model.Setting{Key: "PasswordTimeOut", Value: time.Now().AddDate(0, 0, 10).Format("2016.01.02 15:04:05")}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-09-15 10:44:43 +08:00
|
|
|
if err := tx.Create(&model.Setting{Key: "ComplexityVerification", Value: "enable"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "MFAStatus", Value: "disable"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-09-14 23:27:17 +08:00
|
|
|
if err := tx.Create(&model.Setting{Key: "MFASecret", Value: ""}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-09-15 10:44:43 +08:00
|
|
|
|
|
|
|
if err := tx.Create(&model.Setting{Key: "MonitorStatus", Value: "enable"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "MonitorStoreDays", Value: "30"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tx.Create(&model.Setting{Key: "MessageType", Value: "none"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "EmailVars", Value: ""}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "WeChatVars", Value: ""}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := tx.Create(&model.Setting{Key: "DingVars", Value: ""}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|