Skip to content

Commit

Permalink
Fix the issue where flyway does not support mysql5.7 (#3767)
Browse files Browse the repository at this point in the history
Signed-off-by: Zzm0809 <[email protected]>
Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 and Zzm0809 authored Sep 2, 2024
1 parent eda6778 commit b157442
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 317 deletions.
4 changes: 0 additions & 4 deletions dinky-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,6 @@
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-mysql</artifactId>
</dependency>
<dependency>
<groupId>org.dinky</groupId>
<artifactId>dinky-alert-dingtalk</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public String getRawCreateScript(Table table, boolean baseline) {
String tablespace =
configuration.getTablespace() == null ? "" : " TABLESPACE \"" + configuration.getTablespace() + "\"";

return "CREATE TABLE " + table + " (\n" + " \"installed_rank\" INT NOT NULL,\n"
return "CREATE TABLE " + table.getName() + " (\n" + " \"installed_rank\" INT NOT NULL,\n"
+ " \"version\" VARCHAR(50),\n"
+ " \"description\" VARCHAR(200) NOT NULL,\n"
+ " \"type\" VARCHAR(20) NOT NULL,\n"
Expand All @@ -85,9 +85,9 @@ public String getRawCreateScript(Table table, boolean baseline) {
+ " \"success\" BOOLEAN NOT NULL DEFAULT FALSE\n"
+ ")"
+ tablespace + ";\n" + "ALTER TABLE "
+ table + " ADD CONSTRAINT \"" + table.getName() + "_pk\" PRIMARY KEY (\"installed_rank\");\n"
+ table.getName() + " ADD CONSTRAINT \"" + table.getName() + "_pk\" PRIMARY KEY (\"installed_rank\");\n"
+ "CREATE INDEX \""
+ table.getName() + "_s_idx\" ON " + table + " (\"success\");";
+ table.getName() + "_s_idx\" ON " + table.getName() + " (\"success\");";
}

@Override
Expand Down Expand Up @@ -116,15 +116,12 @@ public String getBooleanFalse() {
}

@Override
public String doQuote(String identifier) {
return getOpenQuote()
+ StringUtils.replaceAll(identifier, getCloseQuote(), getEscapedQuote())
+ getCloseQuote();
protected String doQuote(String identifier) {
return pgQuote(identifier);
}

@Override
public String getEscapedQuote() {
return "\"\"";
static String pgQuote(String identifier) {
return "\"" + StringUtils.replaceAll(identifier, "\"", "\"\"") + "\"";
}

@Override
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions dinky-admin/src/main/resources/application-flyway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ spring:
placeholder-prefix: '##{'
placeholder-suffix: '}##'
fail-on-missing-locations: true # Does the non-existent migration file throw an exception
clean-disabled: true

7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<easy.rules.version>4.1.0</easy.rules.version>
<fastjson2.version>2.0.41</fastjson2.version>
<flink.version>1.18.1</flink.version>
<flyway.version>10.10.12</flyway.version>
<flyway.version>7.15.0</flyway.version>
<guava.version>32.1.3-jre</guava.version>
<h2database.version>1.4.200</h2database.version>
<hamcrest.version>1.3</hamcrest.version>
Expand Down Expand Up @@ -129,6 +129,11 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>${flyway.version}</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions script/sql/dinky-pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3305,6 +3305,7 @@ CREATE TABLE dinky_metrics
id SERIAL PRIMARY KEY NOT NULL,
task_id INT,
vertices VARCHAR(255),
vertices_title VARCHAR(255),
metrics VARCHAR(255),
position INT,
show_type VARCHAR(255),
Expand All @@ -3319,6 +3320,7 @@ COMMENT ON TABLE dinky_metrics IS 'metrics layout';
COMMENT ON COLUMN dinky_metrics.id IS 'id';
COMMENT ON COLUMN dinky_metrics.task_id IS 'task id';
COMMENT ON COLUMN dinky_metrics.vertices IS 'vertices';
COMMENT ON COLUMN dinky_metrics.vertices_title IS 'vertices_title';
COMMENT ON COLUMN dinky_metrics.metrics IS 'metrics';
COMMENT ON COLUMN dinky_metrics.position IS 'position';
COMMENT ON COLUMN dinky_metrics.show_type IS 'show type';
Expand Down
Loading

0 comments on commit b157442

Please sign in to comment.