2023-11-14 10:44:09 +00:00
|
|
|
package migrations
|
|
|
|
|
|
|
|
import (
|
2023-11-29 14:04:08 +00:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
2023-11-14 10:44:09 +00:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
2023-11-29 14:04:08 +00:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/service"
|
2023-11-14 10:44:09 +00:00
|
|
|
"github.com/go-gormigrate/gormigrate/v2"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
var UpdateAcmeAccount = &gormigrate.Migration{
|
2023-11-16 06:38:07 +00:00
|
|
|
ID: "20231117-update-acme-account",
|
2023-11-14 10:44:09 +00:00
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
if err := tx.AutoMigrate(&model.WebsiteAcmeAccount{}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2023-11-20 02:44:10 +00:00
|
|
|
|
2023-11-27 06:00:09 +00:00
|
|
|
var AddWebsiteCA = &gormigrate.Migration{
|
2023-12-01 08:54:09 +00:00
|
|
|
ID: "20231125-add-website-ca",
|
2023-11-20 02:44:10 +00:00
|
|
|
Migrate: func(tx *gorm.DB) error {
|
2023-11-27 06:00:09 +00:00
|
|
|
if err := tx.AutoMigrate(&model.WebsiteCA{}); err != nil {
|
2023-11-20 02:44:10 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2023-11-27 04:04:09 +00:00
|
|
|
|
2023-11-27 06:00:09 +00:00
|
|
|
var UpdateWebsiteSSL = &gormigrate.Migration{
|
2023-11-28 07:42:10 +00:00
|
|
|
ID: "20231128-update-website-ssl",
|
2023-11-27 04:04:09 +00:00
|
|
|
Migrate: func(tx *gorm.DB) error {
|
2023-11-27 06:00:09 +00:00
|
|
|
if err := tx.AutoMigrate(&model.WebsiteSSL{}); err != nil {
|
2023-11-27 04:04:09 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2023-11-28 07:00:10 +00:00
|
|
|
|
|
|
|
var AddDockerSockPath = &gormigrate.Migration{
|
|
|
|
ID: "20231128-add-docker-sock-path",
|
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
if err := tx.Create(&model.Setting{Key: "DockerSockPath", Value: "unix:///var/run/docker.sock"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2023-11-29 02:46:07 +00:00
|
|
|
|
|
|
|
var AddDatabaseSSL = &gormigrate.Migration{
|
|
|
|
ID: "20231126-add-database-ssl",
|
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
if err := tx.AutoMigrate(&model.Database{}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2023-11-29 14:04:08 +00:00
|
|
|
|
|
|
|
var AddDefaultCA = &gormigrate.Migration{
|
2023-12-01 08:54:09 +00:00
|
|
|
ID: "20231129-add-default-ca",
|
2023-11-29 14:04:08 +00:00
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
caService := service.NewIWebsiteCAService()
|
|
|
|
if _, err := caService.Create(request.WebsiteCACreate{
|
|
|
|
CommonName: "1Panel-CA",
|
|
|
|
Country: "CN",
|
|
|
|
KeyType: "P256",
|
|
|
|
Name: "1Panel",
|
|
|
|
Organization: "FIT2CLOUD",
|
|
|
|
OrganizationUint: "1Panel",
|
|
|
|
Province: "Beijing",
|
|
|
|
City: "Beijing",
|
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2023-12-04 06:56:09 +00:00
|
|
|
|
|
|
|
var AddSettingRecycleBin = &gormigrate.Migration{
|
|
|
|
ID: "20231129-add-setting-recycle-bin",
|
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
if err := tx.Create(&model.Setting{Key: "FileRecycleBin", Value: "enable"}).Error; err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|