You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/09/07 12:25:58 UTC

[incubator-devlake] 01/03: fix: add pipeline_projects_tables and fix common import

This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 71cc511c7087789700df0758ee8b85f4f1555fbc
Author: abeizn <zi...@merico.dev>
AuthorDate: Wed Sep 7 16:02:07 2022 +0800

    fix: add pipeline_projects_tables and fix common import
---
 .../migrationscripts/20220729_modify_gilab_ci.go   |  6 +--
 .../migrationscripts/20220804_add_pipeline_id.go   |  4 +-
 .../20220907_add_pipeline_projects_tables.go       | 56 ++++++++++++++++++++++
 plugins/gitlab/models/migrationscripts/register.go |  1 +
 4 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/plugins/gitlab/models/migrationscripts/20220729_modify_gilab_ci.go b/plugins/gitlab/models/migrationscripts/20220729_modify_gilab_ci.go
index 709c6ebd..b99e3cc4 100644
--- a/plugins/gitlab/models/migrationscripts/20220729_modify_gilab_ci.go
+++ b/plugins/gitlab/models/migrationscripts/20220729_modify_gilab_ci.go
@@ -21,7 +21,7 @@ import (
 	"context"
 	"time"
 
-	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/migrationscripts/archived"
 	"gorm.io/gorm"
 )
 
@@ -44,7 +44,7 @@ type GitlabPipeline20220729 struct {
 	FinishedAt      *time.Time
 	Coverage        string
 
-	common.NoPKModel
+	archived.NoPKModel
 }
 
 func (GitlabPipeline20220729) TableName() string {
@@ -69,7 +69,7 @@ type GitlabJob20220729 struct {
 	StartedAt       *time.Time
 	FinishedAt      *time.Time
 
-	common.NoPKModel
+	archived.NoPKModel
 }
 
 func (GitlabJob20220729) TableName() string {
diff --git a/plugins/gitlab/models/migrationscripts/20220804_add_pipeline_id.go b/plugins/gitlab/models/migrationscripts/20220804_add_pipeline_id.go
index 5dae2a16..c9e018e2 100644
--- a/plugins/gitlab/models/migrationscripts/20220804_add_pipeline_id.go
+++ b/plugins/gitlab/models/migrationscripts/20220804_add_pipeline_id.go
@@ -21,7 +21,7 @@ import (
 	"context"
 	"time"
 
-	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/migrationscripts/archived"
 	"gorm.io/gorm"
 )
 
@@ -46,7 +46,7 @@ type GitlabJob20220804 struct {
 	StartedAt       *time.Time
 	FinishedAt      *time.Time
 
-	common.NoPKModel
+	archived.NoPKModel
 }
 
 func (GitlabJob20220804) TableName() string {
diff --git a/plugins/gitlab/models/migrationscripts/20220907_add_pipeline_projects_tables.go b/plugins/gitlab/models/migrationscripts/20220907_add_pipeline_projects_tables.go
new file mode 100644
index 00000000..bd2440a8
--- /dev/null
+++ b/plugins/gitlab/models/migrationscripts/20220907_add_pipeline_projects_tables.go
@@ -0,0 +1,56 @@
+/*
+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"
+
+	"github.com/apache/incubator-devlake/models/migrationscripts/archived"
+	"gorm.io/gorm"
+)
+
+type addPipelineProjects struct{}
+
+type GitlabPipelineProjects20220907 struct {
+	ConnectionId uint64 `gorm:"primaryKey"`
+	PipelineId   int    `gorm:"primaryKey"`
+	ProjectId    int    `gorm:"primaryKey;type:varchar(255)"`
+	Ref          string `gorm:"type:varchar(255)"`
+	Sha          string `gorm:"type:varchar(255)"`
+	archived.NoPKModel
+}
+
+func (GitlabPipelineProjects20220907) TableName() string {
+	return "_tool_gitlab_pipeline_projects"
+}
+
+func (*addPipelineProjects) Up(ctx context.Context, db *gorm.DB) error {
+	err := db.Migrator().CreateTable(&GitlabPipelineProjects20220907{})
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func (*addPipelineProjects) Version() uint64 {
+	return 20220907230912
+}
+
+func (*addPipelineProjects) Name() string {
+	return "gitlab add _tool_gitlab_pipeline_projects table"
+}
diff --git a/plugins/gitlab/models/migrationscripts/register.go b/plugins/gitlab/models/migrationscripts/register.go
index 72d78239..f349677e 100644
--- a/plugins/gitlab/models/migrationscripts/register.go
+++ b/plugins/gitlab/models/migrationscripts/register.go
@@ -27,5 +27,6 @@ func All() []migration.Script {
 		new(addInitTables),
 		new(modifyGitlabCI),
 		new(addPipelineID),
+		new(addPipelineProjects),
 	}
 }