Rename link to url (#2812)

As of https://woodpecker-ci.org/docs/next/usage/terminiology#conventions
This commit is contained in:
qwerty287
2023-11-14 17:12:12 +01:00
committed by GitHub
parent 451b71dcd4
commit 342b25826c
45 changed files with 198 additions and 146 deletions

View File

@@ -36,6 +36,26 @@ func (oldSecret021) TableName() string {
return "secrets"
}
type syncRepo021 struct {
OrgID int64 `json:"org_id" xorm:"repo_org_id"`
}
// TableName return database table name for xorm
func (syncRepo021) TableName() string {
return "repos"
}
type repo021 struct {
ID int64 `json:"id,omitempty" xorm:"pk autoincr 'repo_id'"`
OrgID int64 `json:"org_id" xorm:"repo_org_id"`
Owner string `json:"owner" xorm:"UNIQUE(name) 'repo_owner'"`
}
// TableName return database table name for xorm
func (repo021) TableName() string {
return "repos"
}
var addOrgs = task{
name: "add-orgs",
required: true,
@@ -46,7 +66,7 @@ var addOrgs = task{
}
}
if err := sess.Sync(new(model.Org), new(model.Repo), new(model.User)); err != nil {
if err := sess.Sync(new(model.Org), new(syncRepo021), new(model.User)); err != nil {
return fmt.Errorf("sync new models failed: %w", err)
}
@@ -56,7 +76,7 @@ var addOrgs = task{
}
// get all org names from repos
var repos []*model.Repo
var repos []*repo021
if err := sess.Find(&repos); err != nil {
return fmt.Errorf("find all repos failed: %w", err)
}

View File

@@ -0,0 +1,31 @@
// Copyright 2023 Woodpecker Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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 migration
import (
"xorm.io/xorm"
)
var renameLinkToURL = task{
name: "rename-link-to-url",
required: true,
fn: func(sess *xorm.Session) (err error) {
if err := renameColumn(sess, "pipelines", "pipeline_link", "pipeline_forge_url"); err != nil {
return err
}
return renameColumn(sess, "repos", "repo_link", "repo_forge_url")
},
}

View File

@@ -59,6 +59,7 @@ var migrationTasks = []*task{
&alterTableConfigUpdateColumnConfigDataType,
&removePluginOnlyOptionFromSecretsTable,
&convertToNewPipelineErrorFormat,
&renameLinkToURL,
}
var allBeans = []any{