public boolean createTable(Long id, List columns){
return createTable(AppConst.TABLE_PREFIX+id,columns);
}
@Transactional(rollbackFor = Throwable.class)
public boolean dropTables(List ids){
List tableNames=new ArrayList<>();
ids.forEach(id->{
tableNames.add(AppConst.TABLE_PREFIX+id);
});
return dropTable(tableNames);
}
public boolean addColumns(Long id,List columns){
return addColumns(AppConst.TABLE_PREFIX+id,columns);
}
public boolean updateColumns(Long id,List columns,Map<Long,String> oldColumnMap){
return updateColumns(AppConst.TABLE_PREFIX+id,columns,oldColumnMap);
}
public boolean dropColumns(Long id,List columns){
return dropColumns(AppConst.TABLE_PREFIX+id,columns);
}
private String columnType(String type,Integer length){
if(“varchar”.equals(type)){
if(Objects.isNull(length)||length==0){
length=255;
}
return type+“(”+length+“)”;
}
return type;
}
private boolean createTable(String tableName,List columns){
StringBuffer sb = new StringBuffer();
sb.append(“CREATE TABLE IF NOT EXISTS “public”.”“+tableName+”" (\n");
sb.append(““id” int8 NOT NULL,\n”);
columns.forEach(e->{
sb.append(“”“+e.getName() + “” “+columnType(e.getType(),e.getLength())+” “+isNull