mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-30 12:20:33 +00:00
Adjust model database type mapping (#1949)
adjust definitions according to feedback from real world usage (ci.codeberg.org) close #1892 close #1865
This commit is contained in:
parent
6c58e9db9b
commit
7c99c8b843
5 changed files with 8 additions and 21 deletions
|
@ -24,7 +24,7 @@ type Pipeline struct {
|
|||
Parent int64 `json:"parent" xorm:"pipeline_parent"`
|
||||
Event WebhookEvent `json:"event" xorm:"pipeline_event"`
|
||||
Status StatusValue `json:"status" xorm:"INDEX 'pipeline_status'"`
|
||||
Error string `json:"error" xorm:"pipeline_error"`
|
||||
Error string `json:"error" xorm:"LONGTEXT 'pipeline_error'"`
|
||||
Enqueued int64 `json:"enqueued_at" xorm:"pipeline_enqueued"`
|
||||
Created int64 `json:"created_at" xorm:"pipeline_created"`
|
||||
Updated int64 `json:"updated_at" xorm:"updated NOT NULL DEFAULT 0 'updated'"`
|
||||
|
@ -46,7 +46,7 @@ type Pipeline struct {
|
|||
Reviewer string `json:"reviewed_by" xorm:"pipeline_reviewer"`
|
||||
Reviewed int64 `json:"reviewed_at" xorm:"pipeline_reviewed"`
|
||||
Workflows []*Workflow `json:"workflows,omitempty" xorm:"-"`
|
||||
ChangedFiles []string `json:"changed_files,omitempty" xorm:"json 'changed_files'"`
|
||||
ChangedFiles []string `json:"changed_files,omitempty" xorm:"LONGTEXT 'changed_files'"`
|
||||
AdditionalVariables map[string]string `json:"variables,omitempty" xorm:"json 'additional_variables'"`
|
||||
PullRequestLabels []string `json:"pr_labels,omitempty" xorm:"json 'pr_labels'"`
|
||||
} // @name Pipeline
|
||||
|
|
|
@ -36,13 +36,13 @@ const (
|
|||
// Step represents a process in the pipeline.
|
||||
type Step struct {
|
||||
ID int64 `json:"id" xorm:"pk autoincr 'step_id'"`
|
||||
UUID string `json:"uuid" xorm:"UNIQUE INDEX 'step_uuid'"`
|
||||
UUID string `json:"uuid" xorm:"INDEX 'step_uuid'"`
|
||||
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"`
|
||||
Name string `json:"name" xorm:"step_name"`
|
||||
State StatusValue `json:"state" xorm:"step_state"`
|
||||
Error string `json:"error,omitempty" xorm:"VARCHAR(500) step_error"`
|
||||
Error string `json:"error,omitempty" xorm:"TEXT 'step_error'"`
|
||||
Failure string `json:"-" xorm:"step_failure"`
|
||||
ExitCode int `json:"exit_code" xorm:"step_exit_code"`
|
||||
Started int64 `json:"start_time,omitempty" xorm:"step_started"`
|
||||
|
|
|
@ -22,7 +22,7 @@ type Workflow struct {
|
|||
PID int `json:"pid" xorm:"UNIQUE(s) 'workflow_pid'"`
|
||||
Name string `json:"name" xorm:"workflow_name"`
|
||||
State StatusValue `json:"state" xorm:"workflow_state"`
|
||||
Error string `json:"error,omitempty" xorm:"VARCHAR(500) workflow_error"`
|
||||
Error string `json:"error,omitempty" xorm:"TEXT 'workflow_error'"`
|
||||
Started int64 `json:"start_time,omitempty" xorm:"workflow_started"`
|
||||
Stopped int64 `json:"end_time,omitempty" xorm:"workflow_stopped"`
|
||||
AgentID int64 `json:"agent_id,omitempty" xorm:"workflow_agent_id"`
|
||||
|
|
|
@ -27,7 +27,7 @@ type oldStep020 struct {
|
|||
PPID int `xorm:"step_ppid"`
|
||||
Name string `xorm:"step_name"`
|
||||
State model.StatusValue `xorm:"step_state"`
|
||||
Error string `xorm:"VARCHAR(500) step_error"`
|
||||
Error string `xorm:"TEXT 'step_error'"`
|
||||
Started int64 `xorm:"step_started"`
|
||||
Stopped int64 `xorm:"step_stopped"`
|
||||
AgentID int64 `xorm:"step_agent_id"`
|
||||
|
|
|
@ -179,6 +179,8 @@ func TestStepIndexes(t *testing.T) {
|
|||
defer closer()
|
||||
|
||||
sess := store.engine.NewSession()
|
||||
defer sess.Close()
|
||||
|
||||
if err := store.stepCreate(sess, []*model.Step{
|
||||
{
|
||||
UUID: "4db7e5fc-5312-4d02-9e14-b51b9e3242cc",
|
||||
|
@ -206,21 +208,6 @@ func TestStepIndexes(t *testing.T) {
|
|||
}); err == nil {
|
||||
t.Errorf("Unexpected error: duplicate pid")
|
||||
}
|
||||
|
||||
// fail due to duplicate uuid
|
||||
if err := store.stepCreate(sess, []*model.Step{
|
||||
{
|
||||
UUID: "4db7e5fc-5312-4d02-9e14-b51b9e3242cc",
|
||||
PipelineID: 5,
|
||||
PID: 4,
|
||||
PPID: 3,
|
||||
State: "success",
|
||||
Name: "clone",
|
||||
},
|
||||
}); err == nil {
|
||||
t.Errorf("Unexpected error: duplicate pid")
|
||||
}
|
||||
_ = sess.Close()
|
||||
}
|
||||
|
||||
func TestStepByUUID(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue