You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by li...@apache.org on 2022/10/18 08:07:55 UTC

[incubator-devlake] 01/02: docs: add comments and rename scripts

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

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

commit 17b01f25f604547d18ffed6ee95d9bc34b7509cf
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Tue Oct 18 15:17:05 2022 +0800

    docs: add comments and rename scripts
---
 models/migrationscripts/20220406_add_frame_tables.go         |  1 +
 .../20220505_rename_pipeline_step_to_stage.go                |  1 +
 models/migrationscripts/20220616_add_blueprint_mode.go       |  1 +
 .../migrationscripts/20220913_fix_commitfile_id_toolong.go   |  4 ++++
 ...inutes.go => 20220929_change_leadtimeminutes_to_int64.go} | 12 +++++++-----
 models/migrationscripts/register.go                          |  2 +-
 6 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/models/migrationscripts/20220406_add_frame_tables.go b/models/migrationscripts/20220406_add_frame_tables.go
index 3e014b54..6800a892 100644
--- a/models/migrationscripts/20220406_add_frame_tables.go
+++ b/models/migrationscripts/20220406_add_frame_tables.go
@@ -30,6 +30,7 @@ var _ core.MigrationScript = (*addFrameworkTables)(nil)
 type addFrameworkTables struct{}
 
 func (*addFrameworkTables) Up(basicRes core.BasicRes) errors.Error {
+	// To create multiple tables with migrationhelper
 	return migrationhelper.AutoMigrateTables(
 		basicRes,
 		&archived.Task{},
diff --git a/models/migrationscripts/20220505_rename_pipeline_step_to_stage.go b/models/migrationscripts/20220505_rename_pipeline_step_to_stage.go
index 79d10616..f2b03f9a 100644
--- a/models/migrationscripts/20220505_rename_pipeline_step_to_stage.go
+++ b/models/migrationscripts/20220505_rename_pipeline_step_to_stage.go
@@ -27,6 +27,7 @@ var _ core.MigrationScript = (*renamePipelineStepToStage)(nil)
 type renamePipelineStepToStage struct{}
 
 func (*renamePipelineStepToStage) Up(basicRes core.BasicRes) errors.Error {
+	// rename column `step` to `stage` for table `_devlake_pipelines`
 	return basicRes.GetDal().RenameColumn("_devlake_pipelines", "step", "stage")
 }
 
diff --git a/models/migrationscripts/20220616_add_blueprint_mode.go b/models/migrationscripts/20220616_add_blueprint_mode.go
index 3d7cd319..4c8bce3b 100644
--- a/models/migrationscripts/20220616_add_blueprint_mode.go
+++ b/models/migrationscripts/20220616_add_blueprint_mode.go
@@ -37,6 +37,7 @@ func (blueprint20220616) TableName() string {
 type addBlueprintMode struct{}
 
 func (*addBlueprintMode) Up(basicRes core.BasicRes) errors.Error {
+	// Add column `mode` and `is_manual` with default value "ADVANCED" and false to `_devlake_blueprints`
 	db := basicRes.GetDal()
 	err := db.AutoMigrate(&blueprint20220616{})
 	if err != nil {
diff --git a/models/migrationscripts/20220913_fix_commitfile_id_toolong.go b/models/migrationscripts/20220913_fix_commitfile_id_toolong.go
index 70470870..7374d269 100644
--- a/models/migrationscripts/20220913_fix_commitfile_id_toolong.go
+++ b/models/migrationscripts/20220913_fix_commitfile_id_toolong.go
@@ -51,6 +51,10 @@ type commitFileComponent20220913 struct {
 }
 
 func (script *fixCommitFileIdTooLong) Up(basicRes core.BasicRes) errors.Error {
+	// To recalculate the primary key values for the `commit_files` since
+	// we used the `FilePath` as part of the primary key which would exceed
+	// the maximum length of the column in some cases.
+	// The purpose of this script is to replace the `FilePath` with its sha1
 	// migrate main table
 	err := migrationhelper.TransformTable(
 		basicRes,
diff --git a/models/migrationscripts/20220929_modify_lead_time_minutes.go b/models/migrationscripts/20220929_change_leadtimeminutes_to_int64.go
similarity index 81%
rename from models/migrationscripts/20220929_modify_lead_time_minutes.go
rename to models/migrationscripts/20220929_change_leadtimeminutes_to_int64.go
index 81bd65ce..d789dc4a 100644
--- a/models/migrationscripts/20220929_modify_lead_time_minutes.go
+++ b/models/migrationscripts/20220929_change_leadtimeminutes_to_int64.go
@@ -23,9 +23,9 @@ import (
 	"github.com/apache/incubator-devlake/plugins/core/dal"
 )
 
-var _ core.MigrationScript = (*modifyLeadTimeMinutes)(nil)
+var _ core.MigrationScript = (*changeLeadTimeMinutesToInt64)(nil)
 
-type modifyLeadTimeMinutes struct{}
+type changeLeadTimeMinutesToInt64 struct{}
 
 type Issues20220929 struct {
 	LeadTimeMinutes int64
@@ -35,7 +35,9 @@ func (Issues20220929) TableName() string {
 	return "issues"
 }
 
-func (*modifyLeadTimeMinutes) Up(basicRes core.BasicRes) errors.Error {
+func (*changeLeadTimeMinutesToInt64) Up(basicRes core.BasicRes) errors.Error {
+	// Yes, issues.lead_time_minutes might be negative, we ought to change the type
+	// for the column from `uint` to `int64`
 	db := basicRes.GetDal()
 	bakColumnName := "lead_time_minutes_20220929"
 	err := db.RenameColumn("issues", "lead_time_minutes", bakColumnName)
@@ -72,10 +74,10 @@ func (*modifyLeadTimeMinutes) Up(basicRes core.BasicRes) errors.Error {
 	return nil
 }
 
-func (*modifyLeadTimeMinutes) Version() uint64 {
+func (*changeLeadTimeMinutesToInt64) Version() uint64 {
 	return 20220929145125
 }
 
-func (*modifyLeadTimeMinutes) Name() string {
+func (*changeLeadTimeMinutesToInt64) Name() string {
 	return "modify lead_time_minutes"
 }
diff --git a/models/migrationscripts/register.go b/models/migrationscripts/register.go
index a862dc24..225da018 100644
--- a/models/migrationscripts/register.go
+++ b/models/migrationscripts/register.go
@@ -49,7 +49,7 @@ func All() []core.MigrationScript {
 		new(addRawDataOriginToBoardRepos),
 		new(renamePipelineCommits),
 		new(commitLineChange),
-		new(modifyLeadTimeMinutes),
+		new(changeLeadTimeMinutesToInt64),
 		new(addRepoSnapshot),
 	}
 }