Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 客户端查询列表新增“最后一次拉取配置耗时”字段 #3526

Merged
merged 1 commit into from
Sep 23, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

package migrations

import (
"gorm.io/gorm"

"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/cmd/data-service/db-migration/migrator"
)

func init() {
// add current migration to migrator
migrator.GetMigrator().AddMigration(&migrator.Migration{
Version: "20240914104733",
Name: "20240914104733_modif_client",
Mode: migrator.GormMode,
Up: mig20240914104733Up,
Down: mig20240914104733Down,
})
}

// mig20240914104733Up for up migration
func mig20240914104733Up(tx *gorm.DB) error {

// Clients : clients
type Clients struct {
TotalSeconds float64 `gorm:"column:total_seconds;type:double unsigned;default:0;NOT NULL"`
}

// Clients add new column
if !tx.Migrator().HasColumn(&Clients{}, "total_seconds") {
if err := tx.Migrator().AddColumn(&Clients{}, "total_seconds"); err != nil {
return err
}
}

return nil
}

// mig20240914104733Down for down migration
func mig20240914104733Down(tx *gorm.DB) error {

// Clients : clients
type Clients struct {
TotalSeconds float64 `gorm:"column:total_seconds;type:double unsigned;default:0;NOT NULL"`
}

// Clients drop column
if tx.Migrator().HasColumn(&Clients{}, "total_seconds") {
if err := tx.Migrator().DropColumn(&Clients{}, "total_seconds"); err != nil {
return err
}
}

return nil
}
2 changes: 1 addition & 1 deletion bcs-services/bcs-bscp/pkg/dal/dao/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ func (dao *clientDao) UpsertVersionChange(kit *kit.Kit, tx *gen.QueryTx, data []
"current_release_id", "target_release_id", "specific_failed_reason",
"release_change_status", "release_change_failed_reason", "failed_detail_reason",
"cpu_usage", "cpu_max_usage", "cpu_min_usage", "cpu_avg_usage",
"memory_usage", "memory_max_usage", "memory_min_usage", "memory_avg_usage",
"memory_usage", "memory_max_usage", "memory_min_usage", "memory_avg_usage", "total_seconds",
}),
}).CreateInBatches(data, 500)
}
6 changes: 5 additions & 1 deletion bcs-services/bcs-bscp/pkg/dal/gen/clients.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion bcs-services/bcs-bscp/pkg/dal/table/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ type ClientSpec struct {
CurrentReleaseID uint32 `gorm:"column:current_release_id" json:"current_release_id"`
TargetReleaseID uint32 `gorm:"column:target_release_id" json:"target_release_id"`
ReleaseChangeStatus Status `gorm:"column:release_change_status" json:"release_change_status"`
ReleaseChangeFailedReason string `gorm:"column:release_change_failed_reason" json:"release_change_failed_reason"` // nolint
ReleaseChangeFailedReason string `gorm:"column:release_change_failed_reason" json:"release_change_failed_reason"`
SpecificFailedReason string `gorm:"column:specific_failed_reason" json:"specific_failed_reason"`
FailedDetailReason string `gorm:"column:failed_detail_reason" json:"failed_detail_reason"`
TotalSeconds float64 `gorm:"column:total_seconds" json:"total_seconds"`
}

// ClientAttachment is a client attachment
Expand Down
Loading
Loading