Skip to content

Commit

Permalink
Merge pull request #2591 from wusendong/solve_3.2
Browse files Browse the repository at this point in the history
移除升级到3.2.x时遗留的脏数据

Former-commit-id: c6339a1
  • Loading branch information
breezelxp authored Jun 21, 2019
2 parents a30c192 + 6f0c85c commit e288ae1
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ func reconcilAsstData(ctx context.Context, db dal.RDB, conf *upgrader.Config) er

asst.OnDelete = metadata.NoAction
asst.IsPre = pfalse()

blog.InfoJSON("obj: %s, att: %s to asst %s", asst.ObjectID, asst.ObjectAttID, asst)
}
_, _, err = upgrader.Upsert(ctx, db, common.BKTableNameObjAsst, asst, "id", []string{"bk_obj_id", "bk_asst_obj_id"}, []string{"id"})
if err != nil {
Expand Down Expand Up @@ -219,6 +221,12 @@ func reconcilAsstData(ctx context.Context, db dal.RDB, conf *upgrader.Config) er
return err
}
}

delCond := condition.CreateCondition()
delCond.Field(common.AssociationKindIDField).Eq(nil)
if err = db.Table(common.BKTableNameObjAsst).Delete(ctx, delCond.ToMapStr()); err != nil {
return err
}
return nil
}

Expand Down

0 comments on commit e288ae1

Please sign in to comment.