Skip to content

Commit

Permalink
fix-sql不换行导致的执行错误
Browse files Browse the repository at this point in the history
  • Loading branch information
18940818955 committed Dec 10, 2019
1 parent d80bbff commit aabbaa6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
Expand Down Expand Up @@ -103,7 +104,7 @@ public void resolveCreateSql() {
// 创建key
Key create = (Key) difference;
String createSql = create.getCreateSql();
this.sqlList.add(createSql);
this.sqlList.addAll(Arrays.asList(createSql.split("\n")));
} else if (difference instanceof Column) {
// 创建字段
Column create = (Column) difference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public String getCreateSql() {
sb.append("ALTER TABLE `").append(this.tableName).append("` ADD UNIQUE KEY `").append(this.name).append("` (`").append(this.columnName).append("`);");
} else {
// 外键
sb.append("ALTER TABLE `").append(this.tableName).append("` ADD KEY `").append(this.name).append("` (`").append(this.columnName).append("`);");
sb.append("ALTER TABLE `").append(this.tableName).append("` ADD KEY `").append(this.name).append("` (`").append(this.columnName).append("`);\n");
sb.append("ALTER TABLE `").append(this.tableName).append("` ADD CONSTRAINT `").append(this.name).append("` ")
.append("FOREIGN KEY (`").append(this.columnName).append("`) ")
.append("REFERENCES `").append(this.referencedTable).append("` ")
Expand Down

0 comments on commit aabbaa6

Please sign in to comment.