This is an automated email from the ASF dual-hosted git repository.
hez 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 2e15942a9 fix: Set type of description column to TEXT (#5191)
2e15942a9 is described below
commit 2e15942a92ad6985d5d8bf82f1120999f9a76c2b
Author: Camille Teruel <[email protected]>
AuthorDate: Tue May 16 03:19:59 2023 +0200
fix: Set type of description column to TEXT (#5191)
* fix: Set type of description column to TEXT
* fix: Make PR.merge_commit_sha optional
Abandonned PRs don't have lastMergeCommit property.
---------
Co-authored-by: Camille Teruel <[email protected]>
---
backend/python/plugins/azuredevops/azuredevops/models.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/backend/python/plugins/azuredevops/azuredevops/models.py
b/backend/python/plugins/azuredevops/azuredevops/models.py
index 5952f410b..87c2c423e 100644
--- a/backend/python/plugins/azuredevops/azuredevops/models.py
+++ b/backend/python/plugins/azuredevops/azuredevops/models.py
@@ -18,7 +18,7 @@ from enum import Enum
from typing import Optional
import re
-from sqlmodel import Session
+from sqlmodel import Session, Column, Text
from pydevlake import Field, Connection, TransformationRule
from pydevlake.model import ToolModel, ToolScope
@@ -52,7 +52,7 @@ class GitPullRequest(ToolModel, table=True):
Completed = "completed"
pull_request_id: int = Field(primary_key=True)
- description: Optional[str]
+ description: Optional[str] = Field(sa_column=Column(Text))
status: PRStatus
created_by_id: str = Field(source='/createdBy/id')
created_by_name: str = Field(source='/createdBy/displayName')
@@ -60,7 +60,7 @@ class GitPullRequest(ToolModel, table=True):
closed_date: Optional[datetime.datetime]
source_commit_sha: str = Field(source='/lastMergeSourceCommit/commitId')
target_commit_sha: str = Field(source='/lastMergeTargetCommit/commitId')
- merge_commit_sha: str = Field(source='/lastMergeCommit/commitId')
+ merge_commit_sha: Optional[str] = Field(source='/lastMergeCommit/commitId')
url: Optional[str]
type: Optional[str] = Field(source='/labels/0/name') # TODO: get this off
transformation rules regex
title: Optional[str]
@@ -68,6 +68,14 @@ class GitPullRequest(ToolModel, table=True):
source_ref_name: Optional[str]
fork_repo_id: Optional[str] = Field(source='/forkSource/repository/id')
+ @classmethod
+ def migrate(self, session: Session):
+ dialect = session.bind.dialect.name
+ if dialect == 'mysql':
+ session.execute(f'ALTER TABLE {self.__tablename__} MODIFY COLUMN
description TEXT')
+ elif dialect == 'postgresql':
+ session.execute(f'ALTER TABLE {self.__tablename__} ALTER COLUMN
description TYPE TEXT')
+
class GitPullRequestCommit(ToolModel, table=True):
commit_id: str = Field(primary_key=True)