2019-10-23 17:18:32 +05:30
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2019-10-23 17:18:32 +05:30
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
package v1_11 //nolint
|
2019-10-23 17:18:32 +05:30
|
|
|
|
|
|
|
import (
|
2022-11-02 14:24:36 +05:30
|
|
|
"code.gitea.io/gitea/models/migrations/base"
|
|
|
|
|
2019-10-23 17:18:32 +05:30
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
func RemoveLabelUneededCols(x *xorm.Engine) error {
|
2019-10-23 17:18:32 +05:30
|
|
|
// Make sure the columns exist before dropping them
|
|
|
|
type Label struct {
|
|
|
|
QueryString string
|
|
|
|
IsSelected bool
|
|
|
|
}
|
2023-08-14 00:47:21 +05:30
|
|
|
if err := x.Sync(new(Label)); err != nil {
|
2019-10-23 17:18:32 +05:30
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
sess := x.NewSession()
|
|
|
|
defer sess.Close()
|
|
|
|
if err := sess.Begin(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-11-02 14:24:36 +05:30
|
|
|
if err := base.DropTableColumns(sess, "label", "query_string"); err != nil {
|
2019-10-23 17:18:32 +05:30
|
|
|
return err
|
|
|
|
}
|
2022-11-02 14:24:36 +05:30
|
|
|
if err := base.DropTableColumns(sess, "label", "is_selected"); err != nil {
|
2019-10-23 17:18:32 +05:30
|
|
|
return err
|
|
|
|
}
|
|
|
|
return sess.Commit()
|
|
|
|
}
|