You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "keon94 (via GitHub)" <gi...@apache.org> on 2023/08/25 16:53:12 UTC

[GitHub] [incubator-devlake] keon94 commented on a diff in pull request #5957: Fix azure devops migration from 0.17 to 0.18

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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org