klesh commented on code in PR #3473:
URL: https://github.com/apache/incubator-devlake/pull/3473#discussion_r999069174


##########
impl/dalgorm/dalgorm.go:
##########
@@ -190,6 +190,21 @@ func (d *Dalgorm) AddColumn(table, columnName, columnType 
string) errors.Error {
        return d.Exec("ALTER TABLE ? ADD ? ?", clause.Table{Name: table}, 
clause.Column{Name: columnName}, clause.Expr{SQL: columnType})
 }
 
+// AddTablerColumn add colume with Tabler args
+func (d *Dalgorm) AddTablerColumn(dst dal.Tabler, field string) errors.Error {

Review Comment:
   Can't we use `AutoMigrate`? 



##########
plugins/gitlab/models/migrationscripts/20220906_fix_duration_to_float8.go:
##########
@@ -40,40 +40,46 @@ func (GitlabJob20220906) TableName() string {
        return "_tool_gitlab_jobs"
 }
 
-func (*fixDurationToFloat8) Up(ctx context.Context, db *gorm.DB) errors.Error {
-       err := db.Migrator().AddColumn(&GitlabJob20220906{}, `duration2`)
+func (*fixDurationToFloat8) Up(baseRes core.BasicRes) errors.Error {
+       db := baseRes.GetDal()
+       err := db.AddTablerColumn(&GitlabJob20220906{}, `duration2`)

Review Comment:
   FYI 
https://github.com/apache/incubator-devlake/blob/main/models/migrationscripts/20220929_change_leadtimeminutes_to_int64.go



##########
plugins/gitlab/models/migrationscripts/20220729_modify_gilab_ci.go:
##########
@@ -77,15 +78,16 @@ func (GitlabJob20220729) TableName() string {
        return "_tool_gitlab_jobs"
 }
 
-func (*modifyGitlabCI) Up(ctx context.Context, db *gorm.DB) errors.Error {
-       err := db.Migrator().AddColumn(&GitlabPipeline20220729{}, 
"gitlab_updated_at")
+func (*modifyGitlabCI) Up(baseRes core.BasicRes) errors.Error {
+       db := baseRes.GetDal()
+       err := db.AddTablerColumn(&GitlabPipeline20220729{}, 
"gitlab_updated_at")

Review Comment:
   `model struct` must be camelCase: GitlabPipeline20220729 -> 
gitlabPipeline20220729



##########
impl/dalgorm/dalgorm.go:
##########
@@ -207,6 +222,21 @@ func (d *Dalgorm) DropColumns(table string, columnNames 
...string) errors.Error
        return nil
 }
 
+// DropTablerColumn drop colume with Tabler args
+func (d *Dalgorm) DropTablerColumn(dst dal.Tabler, field string) errors.Error {

Review Comment:
   What is the necessity of it? Can't we use `DropColumns`



##########
plugins/gitlab/models/migrationscripts/20220729_modify_gilab_ci.go:
##########
@@ -18,12 +18,13 @@ limitations under the License.
 package migrationscripts
 
 import (
-       "context"
-       "github.com/apache/incubator-devlake/errors"
        "time"
 
+       "github.com/apache/incubator-devlake/errors"
+       "github.com/apache/incubator-devlake/helpers/migrationhelper"
+       "github.com/apache/incubator-devlake/plugins/core"
+
        "github.com/apache/incubator-devlake/models/migrationscripts/archived"
-       "gorm.io/gorm"
 )
 
 type modifyGitlabCI struct{}

Review Comment:
   Please rename the name of the script to a more descriptive one



##########
plugins/gitlab/models/migrationscripts/20220906_fix_duration_to_float8.go:
##########
@@ -40,40 +40,46 @@ func (GitlabJob20220906) TableName() string {
        return "_tool_gitlab_jobs"
 }
 
-func (*fixDurationToFloat8) Up(ctx context.Context, db *gorm.DB) errors.Error {
-       err := db.Migrator().AddColumn(&GitlabJob20220906{}, `duration2`)
+func (*fixDurationToFloat8) Up(baseRes core.BasicRes) errors.Error {
+       db := baseRes.GetDal()
+       err := db.AddTablerColumn(&GitlabJob20220906{}, `duration2`)

Review Comment:
   or use `migrationhelper.Transform`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to