크리에이티브 커먼즈 라이선스
Creative Commons License

 


exERD xScript 이용하여 컬럼 기본값 변경하기

 

 

xScript 이용하여 외래키명 바꾸기

 

var targetName = "physical-name";

select(function(it) {
   return it.get("type") == "foreign-key";
}).each(function(it) {
   if(it.get("schema").get("physical-name") == "SCHEMA_2016")
   {
      var parentTable = it.get("parent-table");
      var childTable = it.get("child-table");

      var parentMatcher = compilePattern("^TB_.*").matcher(parentTable.get(targetName));
      var childMatcher = compilePattern("^TB_.*").matcher(childTable.get(targetName));
      if(parentMatcher.matches() && childMatcher.matches())
      {
         var parentName = parentMatcher.group().replace("TB_", "");
         var childName = childMatcher.group().replace("TB_", "");

         var newName = "FK_";
         var tmp1 = parentName.split("_");
         for(var idx in tmp1)
            newName += tmp1[idx].substr(0, 1);

         newName += "_TO_";

         var tmp2 = childName.split("_");
         for(var idx in tmp2)
            newName += tmp2[idx].substr(0, 1);
      }

      if(newName != undefined && it.get("physical-name") != newName)
      {
         log(it.get(targetName));
         //it.set(targetName, newName);
      }
   }
});


make by Kang

 

 

 


저작자 표시 비영리 변경 금지
신고

+ Recent posts