|
@@ -53,7 +53,7 @@ public class KbSqlFileWork extends AbstractFileWork { |
|
|
if (sql.contains("ADD")) { |
|
|
if (sql.contains("ADD")) { |
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()); |
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()); |
|
|
sql = sql.substring(sql.indexOf("ADD COLUMN")); |
|
|
sql = sql.substring(sql.indexOf("ADD COLUMN")); |
|
|
String[] sqls = sql.split(","); |
|
|
|
|
|
|
|
|
String[] sqls = sql.split(",(?=(?:[^\']*\'[^\']*\')*[^\']*$)", -1); |
|
|
for (String str : sqls) { |
|
|
for (String str : sqls) { |
|
|
String[] ss = str.split(" "); |
|
|
String[] ss = str.split(" "); |
|
|
sb.append(" ADD COLUMN ").append(ss[2]).append(" ").append(convertFieldType(ss[3])).append(" NULL ").append(","); |
|
|
sb.append(" ADD COLUMN ").append(ss[2]).append(" ").append(convertFieldType(ss[3])).append(" NULL ").append(","); |
|
@@ -62,7 +62,7 @@ public class KbSqlFileWork extends AbstractFileWork { |
|
|
} else if (sql.contains("DROP")) { |
|
|
} else if (sql.contains("DROP")) { |
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()); |
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()); |
|
|
sql = sql.substring(sql.indexOf("DROP COLUMN")); |
|
|
sql = sql.substring(sql.indexOf("DROP COLUMN")); |
|
|
String[] sqls = sql.split(","); |
|
|
|
|
|
|
|
|
String[] sqls = sql.split(",(?=(?:[^\']*\'[^\']*\')*[^\']*$)", -1); |
|
|
for (String str : sqls) { |
|
|
for (String str : sqls) { |
|
|
String[] ss = str.split(" "); |
|
|
String[] ss = str.split(" "); |
|
|
sb.append(" DROP COLUMN ").append(ss[2]).append(","); |
|
|
sb.append(" DROP COLUMN ").append(ss[2]).append(","); |
|
@@ -71,7 +71,7 @@ public class KbSqlFileWork extends AbstractFileWork { |
|
|
|
|
|
|
|
|
} else if (sql.contains("CHANGE")) { |
|
|
} else if (sql.contains("CHANGE")) { |
|
|
sql = sql.substring(sql.indexOf("CHANGE COLUMN")); |
|
|
sql = sql.substring(sql.indexOf("CHANGE COLUMN")); |
|
|
String[] sqls = sql.split(","); |
|
|
|
|
|
|
|
|
String[] sqls = sql.split(",(?=(?:[^\']*\'[^\']*\')*[^\']*$)", -1); |
|
|
for (String str : sqls) { |
|
|
for (String str : sqls) { |
|
|
String[] ss = str.split(" "); |
|
|
String[] ss = str.split(" "); |
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()).append(" RENAME COLUMN ").append(ss[2]).append(" TO ").append(ss[3]).append(";"); |
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()).append(" RENAME COLUMN ").append(ss[2]).append(" TO ").append(ss[3]).append(";"); |
|
@@ -80,7 +80,7 @@ public class KbSqlFileWork extends AbstractFileWork { |
|
|
} else if (sql.contains("MODIFY")) { |
|
|
} else if (sql.contains("MODIFY")) { |
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()); |
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()); |
|
|
sql = sql.substring(sql.indexOf("MODIFY COLUMN")); |
|
|
sql = sql.substring(sql.indexOf("MODIFY COLUMN")); |
|
|
String[] sqls = sql.split(","); |
|
|
|
|
|
|
|
|
String[] sqls = sql.split(",(?=(?:[^\']*\'[^\']*\')*[^\']*$)", -1); |
|
|
for (String str : sqls) { |
|
|
for (String str : sqls) { |
|
|
String[] ss = str.split(" "); |
|
|
String[] ss = str.split(" "); |
|
|
sb.append(" ALTER COLUMN ").append(ss[2]).append(" TYPE ").append(convertFieldType(ss[3])).append(","); |
|
|
sb.append(" ALTER COLUMN ").append(ss[2]).append(" TYPE ").append(convertFieldType(ss[3])).append(","); |
|
|