keon94 commented on code in PR #5957:
URL: 
https://github.com/apache/incubator-devlake/pull/5957#discussion_r1305912786


##########
backend/server/services/remote/models/migration.go:
##########
@@ -101,6 +101,28 @@ func (o DropTableOperation) Execute(basicRes 
context.BasicRes) errors.Error {
 
 var _ Operation = (*DropTableOperation)(nil)
 
+type RenameColumnOperation struct {
+       Table   string `json:"table"`
+       OldName string `json:"old_name"`
+       NewName string `json:"new_name"`
+}
+
+func (o RenameColumnOperation) Execute(basicRes context.BasicRes) errors.Error 
{
+       db := basicRes.GetDal()
+       if !db.HasColumn(o.Table, o.OldName) {
+               return nil
+       }
+       if db.HasColumn(o.Table, o.NewName) {
+               err := db.DropColumns(o.Table, o.NewName)

Review Comment:
   why should we drop the column if it exists? That'll cause data loss. Isn't 
just doing RenameColumn() enough?



-- 
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