Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/init/migration/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func Init() {
migrations.InitTerminalSetting,
migrations.InitGoogle,
migrations.AddTaskDB,
migrations.UpdateDeveloperMode,
migrations.AddXpackHideMenu,
})
if err := m.Migrate(); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UpdateDeveloperMode function call should be removed from the migration list unless that functionality is intended to be executed within a specific migration step. This could potentially lead to missing updates if migrations are executed independently.

Expand Down
13 changes: 2 additions & 11 deletions core/init/migration/migrations/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package migrations
import (
"encoding/json"
"fmt"
"github.com/1Panel-dev/1Panel/core/app/dto"
"path"
"strings"
"time"

"github.com/1Panel-dev/1Panel/core/app/dto"

"github.com/1Panel-dev/1Panel/core/app/model"
"github.com/1Panel-dev/1Panel/core/constant"
"github.com/1Panel-dev/1Panel/core/global"
Expand Down Expand Up @@ -274,16 +275,6 @@ var AddTaskDB = &gormigrate.Migration{
},
}

var UpdateDeveloperMode = &gormigrate.Migration{
ID: "20240516-update-developer-mode",
Migrate: func(tx *gorm.DB) error {
if err := tx.Model(&model.Setting{}).Where("key = ?", "DeveloperMode").Update("value", constant.StatusEnable).Error; err != nil {
return err
}
return nil
},
}

var AddXpackHideMenu = &gormigrate.Migration{
ID: "20250529-add-xpack-hide-menu",
Migrate: func(tx *gorm.DB) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be some redundant imports near the bottom of the file that can cause confusion. Here's an optimized version:

package migrations

import (
	"encoding/json"
	"fmt"
	"path"
	"strings"
	"time"

	dbModel "github.com/1Panel-dev/1Panel/core/app/model"
	constant "github.com/1Panel-dev/1Panel/core/constant"
)

var AddTaskDB = &gormigrate.Migration{
	ID: "20240516-add-task-db",
	Migrate: func(tx *gorm.DB) error {
		return dbModel.Task{}.DropTableIfExists().
			CreateTables(dbModel.Task{})
	},
}

// var UpdateDeveloperMode is unused and can be deleted.

Additionally, adding dbModel before each call simplifies the usage since it clearly indicates which package they belong to.

This ensures the code is clean and easier to read while maintaining functionality.

Expand Down
Loading