Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modify _tool_jira_issue_relationships primary key #6253

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
connection_id,issue_id,issue_key,type_id,type_name,inward,outward,inward_issue_id,inward_issue_key,outward_issue_id,outward_issue_key
2,10802,DZFNK0168-1,10000,Blocks,is blocked by,blocks,10806,DZFNK0168-5,0,
2,10803,DZFNK0168-2,10000,Blocks,is blocked by,blocks,0,,10823,DZFNK0168-22
2,10805,DZFNK0168-4,10001,Cloners,is cloned by,clones,0,,10812,DZFNK0168-11
2,10806,DZFNK0168-5,10002,Duplicate,is duplicated by,duplicates,10812,DZFNK0168-11,0,
2,10812,DZFNK0168-11,10002,Duplicate,is duplicated by,duplicates,116583,IP8CUD168-35305,0,
2,10815,DZFNK0168-14,10002,Duplicate,is duplicated by,duplicates,0,,116566,IP8CUD168-35288
2,10817,DZFNK0168-16,10001,Cloners,is cloned by,clones,111957,M2VRIQ168-12985,0,
2,10818,DZFNK0168-17,10001,Cloners,is cloned by,clones,0,,111900,M2VRIQ168-12954
2,10820,DZFNK0168-19,10003,Relates,relates to,relates to,0,,10822,DZFNK0168-21
2,10821,DZFNK0168-20,10000,Blocks,is blocked by,blocks,116684,IP8CUD168-35406,0,
2,10822,DZFNK0168-21,10003,Relates,relates to,relates to,10820,DZFNK0168-19,0,
2,10823,DZFNK0168-22,10000,Blocks,is blocked by,blocks,10803,DZFNK0168-2,0,
connection_id,issue_id,inward_issue_id,outward_issue_id,issue_key,type_id,type_name,inward,outward,inward_issue_key,outward_issue_key
2,10802,10806,0,DZFNK0168-1,10000,Blocks,is blocked by,blocks,DZFNK0168-5,
2,10803,0,10823,DZFNK0168-2,10000,Blocks,is blocked by,blocks,,DZFNK0168-22
2,10805,0,10812,DZFNK0168-4,10001,Cloners,is cloned by,clones,,DZFNK0168-11
2,10806,0,10802,DZFNK0168-5,10000,Blocks,is blocked by,blocks,,DZFNK0168-1
2,10806,10812,0,DZFNK0168-5,10002,Duplicate,is duplicated by,duplicates,DZFNK0168-11,
2,10812,0,10806,DZFNK0168-11,10002,Duplicate,is duplicated by,duplicates,,DZFNK0168-5
2,10812,10805,0,DZFNK0168-11,10001,Cloners,is cloned by,clones,DZFNK0168-4,
2,10812,116583,0,DZFNK0168-11,10002,Duplicate,is duplicated by,duplicates,IP8CUD168-35305,
2,10815,0,116566,DZFNK0168-14,10002,Duplicate,is duplicated by,duplicates,,IP8CUD168-35288
2,10817,111957,0,DZFNK0168-16,10001,Cloners,is cloned by,clones,M2VRIQ168-12985,
2,10818,0,111900,DZFNK0168-17,10001,Cloners,is cloned by,clones,,M2VRIQ168-12954
2,10820,0,10822,DZFNK0168-19,10003,Relates,relates to,relates to,,DZFNK0168-21
2,10821,0,116582,DZFNK0168-20,10000,Blocks,is blocked by,blocks,,IP8CUD168-35304
2,10821,116684,0,DZFNK0168-20,10000,Blocks,is blocked by,blocks,IP8CUD168-35406,
2,10822,10820,0,DZFNK0168-21,10003,Relates,relates to,relates to,DZFNK0168-19,
2,10823,10803,0,DZFNK0168-22,10000,Blocks,is blocked by,blocks,DZFNK0168-2,
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ source_issue_id,target_issue_id,original_type
jira:JiraIssue:2:10802,jira:JiraIssue:2:10806,is blocked by
jira:JiraIssue:2:10803,jira:JiraIssue:2:10823,blocks
jira:JiraIssue:2:10805,jira:JiraIssue:2:10812,clones
jira:JiraIssue:2:10806,jira:JiraIssue:2:10802,blocks
jira:JiraIssue:2:10806,jira:JiraIssue:2:10812,is duplicated by
jira:JiraIssue:2:10812,jira:JiraIssue:2:10805,is cloned by
jira:JiraIssue:2:10812,jira:JiraIssue:2:10806,duplicates
jira:JiraIssue:2:10812,jira:JiraIssue:2:116583,is duplicated by
jira:JiraIssue:2:10815,jira:JiraIssue:2:116566,duplicates
jira:JiraIssue:2:10817,jira:JiraIssue:2:111957,is cloned by
jira:JiraIssue:2:10818,jira:JiraIssue:2:111900,clones
jira:JiraIssue:2:10820,jira:JiraIssue:2:10822,relates to
jira:JiraIssue:2:10821,jira:JiraIssue:2:116582,blocks
jira:JiraIssue:2:10821,jira:JiraIssue:2:116684,is blocked by
jira:JiraIssue:2:10822,jira:JiraIssue:2:10820,relates to
jira:JiraIssue:2:10823,jira:JiraIssue:2:10803,is blocked by
4 changes: 2 additions & 2 deletions backend/plugins/jira/models/issue_relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type JiraIssueRelationship struct {
TypeName string `gorm:"type:varchar(255)"` // e.g. Blocks
Inward string `gorm:"type:varchar(255)"` // e.g. blocks
Outward string `gorm:"type:varchar(255)"` // e.g. is blocked by
InwardIssueId uint64 // e.g. 116566
InwardIssueId uint64 `gorm:"primaryKey"` // e.g. 116566
InwardIssueKey string `gorm:"type:varchar(255)"` // e.g. DEV-2
OutwardIssueId uint64 // e.g. 116567
OutwardIssueId uint64 `gorm:"primaryKey"` // e.g. 116567
OutwardIssueKey string `gorm:"type:varchar(255)"` // e.g. DEV-3
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
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 (
"github.com/apache/incubator-devlake/core/context"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/migrationscripts/archived"
"github.com/apache/incubator-devlake/helpers/migrationhelper"
jiraArchived "github.com/apache/incubator-devlake/plugins/jira/models/migrationscripts/archived"
)

type modifyIssueRelationship struct{}

type JiraIssueRelationship20231016 struct {
archived.NoPKModel
ConnectionId uint64 `gorm:"primaryKey"`
IssueId uint64 `gorm:"primarykey"`
IssueKey string `gorm:"type:varchar(255)"` // e.g. DEV-1
TypeId uint64 // e.g. 10001
TypeName string `gorm:"type:varchar(255)"` // e.g. Blocks
Inward string `gorm:"type:varchar(255)"` // e.g. blocks
Outward string `gorm:"type:varchar(255)"` // e.g. is blocked by
InwardIssueId uint64 `gorm:"primaryKey"` // e.g. 116566
InwardIssueKey string `gorm:"type:varchar(255)"` // e.g. DEV-2
OutwardIssueId uint64 `gorm:"primaryKey"` // e.g. 116567
OutwardIssueKey string `gorm:"type:varchar(255)"` // e.g. DEV-3
}

func (JiraIssueRelationship20231016) TableName() string {
return "_tool_jira_issue_relationships"
}

func (script *modifyIssueRelationship) Up(basicRes context.BasicRes) errors.Error {
err := basicRes.GetDal().DropTables(&jiraArchived.JiraIssueRelationship{})
if err != nil {
return err
}
return migrationhelper.AutoMigrateTables(
basicRes,
&JiraIssueRelationship20231016{},
)
}

func (*modifyIssueRelationship) Version() uint64 {
return 20231016122537
}

func (*modifyIssueRelationship) Name() string {
return "modify _tool_jira_issue_relationships table primary key"
}
1 change: 1 addition & 0 deletions backend/plugins/jira/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ func All() []plugin.MigrationScript {
new(addRawParamTableForScope),
new(addIssueRelationship),
new(dropIssueAllFields),
new(modifyIssueRelationship),
}
}