Drop old columns (#1838)

This commit is contained in:
qwerty287 2023-06-07 19:22:44 +02:00 committed by GitHub
parent 7e708874ae
commit 5d74174bc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 45 additions and 35 deletions

View file

@ -3933,10 +3933,6 @@ const docTemplate = `{
"description": "uses reported user for webhooks and name of cron for cron pipelines",
"type": "string"
},
"signed": {
"description": "deprecate",
"type": "boolean"
},
"started_at": {
"type": "integer"
},
@ -3963,10 +3959,6 @@ const docTemplate = `{
"additionalProperties": {
"type": "string"
}
},
"verified": {
"description": "deprecate",
"type": "boolean"
}
}
},
@ -4230,9 +4222,6 @@ const docTemplate = `{
"name": {
"type": "string"
},
"pgid": {
"type": "integer"
},
"pid": {
"type": "integer"
},

View file

@ -83,7 +83,6 @@ func (b *StepBuilder) Build() ([]*Item, error) {
UUID: uuid.New().String(), // TODO(#1784): Remove once workflows are a separate entity in database
PipelineID: b.Curr.ID,
PID: pidSequence,
PGID: pidSequence,
State: model.StatusPending,
Environ: axis,
Name: SanitizePath(y.Name),
@ -305,7 +304,6 @@ func SetPipelineStepsOnPipeline(pipeline *model.Pipeline, pipelineItems []*Item)
PipelineID: pipeline.ID,
PID: pidSequence,
PPID: item.Workflow.PID,
PGID: gid,
State: model.StatusPending,
}
if item.Workflow.State == model.StatusSkipped {

View file

@ -43,8 +43,6 @@ type Pipeline struct {
Avatar string `json:"author_avatar" xorm:"pipeline_avatar"`
Email string `json:"author_email" xorm:"pipeline_email"`
Link string `json:"link_url" xorm:"pipeline_link"`
Signed bool `json:"signed" xorm:"pipeline_signed"` // deprecate
Verified bool `json:"verified" xorm:"pipeline_verified"` // deprecate
Reviewer string `json:"reviewed_by" xorm:"pipeline_reviewer"`
Reviewed int64 `json:"reviewed_at" xorm:"pipeline_reviewed"`
Steps []*Step `json:"steps,omitempty" xorm:"-"`

View file

@ -35,7 +35,6 @@ type Step struct {
PipelineID int64 `json:"pipeline_id" xorm:"UNIQUE(s) INDEX 'step_pipeline_id'"`
PID int `json:"pid" xorm:"UNIQUE(s) 'step_pid'"`
PPID int `json:"ppid" xorm:"step_ppid"`
PGID int `json:"pgid" xorm:"step_pgid"`
Name string `json:"name" xorm:"step_name"`
State StatusValue `json:"state" xorm:"step_state"`
Error string `json:"error,omitempty" xorm:"VARCHAR(500) step_error"`

View file

@ -27,7 +27,6 @@ func TestTree(t *testing.T) {
PID: 2,
PipelineID: 6,
PPID: 1,
PGID: 2,
Name: "clone",
State: StatusSuccess,
Error: "0",
@ -37,7 +36,6 @@ func TestTree(t *testing.T) {
PipelineID: 6,
PID: 1,
PPID: 0,
PGID: 1,
Name: "lint",
State: StatusFailure,
Error: "1",
@ -47,7 +45,6 @@ func TestTree(t *testing.T) {
PipelineID: 6,
PID: 3,
PPID: 1,
PGID: 3,
Name: "lint",
State: StatusFailure,
Error: "1",
@ -63,7 +60,6 @@ func TestTree(t *testing.T) {
PID: 2,
PipelineID: 6,
PPID: 1,
PGID: 2,
Name: "clone",
State: StatusSuccess,
Error: "0",

View file

@ -81,7 +81,6 @@ func Create(ctx context.Context, _store store.Store, repo *model.Repo, pipeline
// update some pipeline fields
pipeline.RepoID = repo.ID
pipeline.Verified = true
pipeline.Status = model.StatusPending
if configFetchErr != nil {

View file

@ -0,0 +1,44 @@
// 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"
)
type oldPipeline018 struct {
ID int64 `xorm:"pk autoincr 'pipeline_id'"`
Signed bool `xorm:"pipeline_signed"`
Verified bool `xorm:"pipeline_verified"`
}
func (oldPipeline018) TableName() string {
return "pipelines"
}
var dropOldCols = task{
name: "drop-old-col",
fn: func(sess *xorm.Session) error {
// make sure columns on pipelines exist
if err := sess.Sync(new(oldPipeline018)); err != nil {
return err
}
if err := dropTableColumns(sess, "steps", "step_pgid"); err != nil {
return err
}
return dropTableColumns(sess, "pipelines", "pipeline_signed", "pipeline_verified")
},
}

View file

@ -47,6 +47,7 @@ var migrationTasks = []*task{
&removeInactiveRepos,
&dropFiles,
&removeMachineCol,
&dropOldCols,
}
var allBeans = []interface{}{

View file

@ -34,7 +34,6 @@ func TestStepFind(t *testing.T) {
PipelineID: 1000,
PID: 1,
PPID: 2,
PGID: 3,
Name: "build",
State: model.StatusSuccess,
Error: "pc load letter",
@ -65,14 +64,12 @@ func TestStepChild(t *testing.T) {
PipelineID: 1,
PID: 1,
PPID: 1,
PGID: 1,
State: "success",
},
{
UUID: "2bf387f7-2913-4907-814c-c9ada88707c0",
PipelineID: 1,
PID: 2,
PGID: 2,
PPID: 1,
Name: "build",
State: "success",
@ -106,7 +103,6 @@ func TestStepList(t *testing.T) {
PipelineID: 2,
PID: 1,
PPID: 1,
PGID: 1,
State: "success",
},
{
@ -114,14 +110,12 @@ func TestStepList(t *testing.T) {
PipelineID: 1,
PID: 1,
PPID: 1,
PGID: 1,
State: "success",
},
{
UUID: "40aab045-970b-4892-b6df-6f825a7ec97a",
PipelineID: 1,
PID: 2,
PGID: 2,
PPID: 1,
Name: "build",
State: "success",
@ -150,7 +144,6 @@ func TestStepUpdate(t *testing.T) {
PipelineID: 1,
PID: 1,
PPID: 2,
PGID: 3,
Name: "build",
State: "pending",
Error: "pc load letter",
@ -188,7 +181,6 @@ func TestStepIndexes(t *testing.T) {
PipelineID: 1,
PID: 1,
PPID: 1,
PGID: 1,
State: "running",
Name: "build",
},
@ -204,7 +196,6 @@ func TestStepIndexes(t *testing.T) {
PipelineID: 1,
PID: 1,
PPID: 1,
PGID: 1,
State: "success",
Name: "clone",
},
@ -219,7 +210,6 @@ func TestStepIndexes(t *testing.T) {
PipelineID: 5,
PID: 4,
PPID: 3,
PGID: 2,
State: "success",
Name: "clone",
},
@ -238,7 +228,6 @@ func TestStepByUUID(t *testing.T) {
PipelineID: 1,
PID: 1,
PPID: 1,
PGID: 1,
State: "running",
Name: "build",
},
@ -247,7 +236,6 @@ func TestStepByUUID(t *testing.T) {
PipelineID: 4,
PID: 6,
PPID: 7,
PGID: 8,
Name: "build",
State: "pending",
Error: "pc load letter",

View file

@ -106,7 +106,6 @@ export type PipelineStep = {
pipeline_id: number;
pid: number;
ppid: number;
pgid: number;
name: string;
state: PipelineStatus;
exit_code: number;

View file

@ -93,7 +93,6 @@ type (
ID int64 `json:"id"`
PID int `json:"pid"`
PPID int `json:"ppid"`
PGID int `json:"pgid"`
Name string `json:"name"`
State string `json:"state"`
Error string `json:"error,omitempty"`