You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2022/08/29 13:46:28 UTC
[incubator-devlake] branch main updated: feat(domainlayer): modify tables to adapt dora
This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new ccb2817b feat(domainlayer): modify tables to adapt dora
ccb2817b is described below
commit ccb2817b306dc4cc5c3a71cc16ccca2646f9738a
Author: Yingchu Chen <yi...@merico.dev>
AuthorDate: Mon Aug 29 21:21:49 2022 +0800
feat(domainlayer): modify tables to adapt dora
closes #2875
---
models/domainlayer/code/pull_request.go | 5 ++
models/domainlayer/devops/cicd_pipeline.go | 1 +
models/domainlayer/ticket/issue.go | 1 +
.../20220829_modify_tables_for_dora.go | 73 ++++++++++++++++++++++
models/migrationscripts/register.go | 1 +
5 files changed, 81 insertions(+)
diff --git a/models/domainlayer/code/pull_request.go b/models/domainlayer/code/pull_request.go
index e17e6970..64a1d8c8 100644
--- a/models/domainlayer/code/pull_request.go
+++ b/models/domainlayer/code/pull_request.go
@@ -46,6 +46,11 @@ type PullRequest struct {
BaseRef string `gorm:"type:varchar(255)"`
BaseCommitSha string `gorm:"type:varchar(40)"`
HeadCommitSha string `gorm:"type:varchar(40)"`
+ CodingTimespan int64
+ ReviewLag int64
+ ReviewTimespan int64
+ DeployTimespan int64
+ ChangeTimespan int64
}
func (PullRequest) TableName() string {
diff --git a/models/domainlayer/devops/cicd_pipeline.go b/models/domainlayer/devops/cicd_pipeline.go
index 306bed4e..96745b87 100644
--- a/models/domainlayer/devops/cicd_pipeline.go
+++ b/models/domainlayer/devops/cicd_pipeline.go
@@ -16,6 +16,7 @@ type CICDPipeline struct {
Status string `gorm:"type:varchar(100)"`
Type string `gorm:"type:varchar(100);comment: to indicate this is CI or CD"`
DurationSec uint64
+ environment string `gorm:"type:varchar(255)"`
CreatedDate time.Time
FinishedDate *time.Time
}
diff --git a/models/domainlayer/ticket/issue.go b/models/domainlayer/ticket/issue.go
index d057ce50..d1323994 100644
--- a/models/domainlayer/ticket/issue.go
+++ b/models/domainlayer/ticket/issue.go
@@ -50,6 +50,7 @@ type Issue struct {
AssigneeName string `gorm:"type:varchar(255)"`
Severity string `gorm:"type:varchar(255)"`
Component string `gorm:"type:varchar(255)"`
+ DeploymentId string `gorm:"type:varchar(255)"`
}
func (Issue) TableName() string {
diff --git a/models/migrationscripts/20220829_modify_tables_for_dora.go b/models/migrationscripts/20220829_modify_tables_for_dora.go
new file mode 100644
index 00000000..5c0bcb2c
--- /dev/null
+++ b/models/migrationscripts/20220829_modify_tables_for_dora.go
@@ -0,0 +1,73 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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 migrationscripts
+
+import (
+ "context"
+ "gorm.io/gorm"
+)
+
+type modifyTablesForDora struct{}
+
+func (*modifyTablesForDora) Up(ctx context.Context, db *gorm.DB) error {
+ err := db.Migrator().AutoMigrate(
+ &CICDPipeline0829{},
+ &PullRequest0829{},
+ &Issue0829{},
+ )
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func (*modifyTablesForDora) Version() uint64 {
+ return 20220829232735
+}
+
+func (*modifyTablesForDora) Name() string {
+ return "modify tables for dora"
+}
+
+type PullRequest0829 struct {
+ CodingTimespan uint64
+ ReviewLag uint64
+ ReviewTimespan uint64
+ DeployTimespan uint64
+ ChangeTimespan uint64
+}
+
+func (PullRequest0829) TableName() string {
+ return "pull_requests"
+}
+
+type Issue0829 struct {
+ DeploymentId string `gorm:"type:varchar(255)"`
+}
+
+func (Issue0829) TableName() string {
+ return "issues"
+}
+
+type CICDPipeline0829 struct {
+ Environment string `gorm:"type:varchar(255)"`
+}
+
+func (CICDPipeline0829) TableName() string {
+ return "cicd_pipelines"
+}
diff --git a/models/migrationscripts/register.go b/models/migrationscripts/register.go
index 9c91cd8c..f6cd0a20 100644
--- a/models/migrationscripts/register.go
+++ b/models/migrationscripts/register.go
@@ -36,5 +36,6 @@ func All() []migration.Script {
new(addNoPKModelToCommitParent),
new(addSubtasksTable),
new(addCICD),
+ new(modifyTablesForDora),
}
}