fix: Flyway版本号V3→V15匹配当前Schema版本
This commit is contained in:
@@ -5,22 +5,14 @@ import org.flywaydb.core.api.migration.Context;
|
|||||||
|
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
/**
|
public class V15__AddConfigTables extends BaseJavaMigration {
|
||||||
* Flyway V3:新增配置表和字段
|
|
||||||
* - sites 表增加 tags 列
|
|
||||||
* - site_pages 表
|
|
||||||
* - risk_rules 表
|
|
||||||
*/
|
|
||||||
public class V3__AddConfigTables extends BaseJavaMigration {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void migrate(Context context) throws Exception {
|
public void migrate(Context context) throws Exception {
|
||||||
Statement stmt = context.getConnection().createStatement();
|
Statement stmt = context.getConnection().createStatement();
|
||||||
|
|
||||||
// 站点标签
|
|
||||||
stmt.execute("ALTER TABLE sites ADD COLUMN IF NOT EXISTS tags JSON NULL COMMENT '标签列表' AFTER description");
|
stmt.execute("ALTER TABLE sites ADD COLUMN IF NOT EXISTS tags JSON NULL COMMENT '标签列表' AFTER description");
|
||||||
|
|
||||||
// 站点页面配置
|
|
||||||
stmt.execute("CREATE TABLE IF NOT EXISTS site_pages (" +
|
stmt.execute("CREATE TABLE IF NOT EXISTS site_pages (" +
|
||||||
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
||||||
"site_id VARCHAR(64) NOT NULL, " +
|
"site_id VARCHAR(64) NOT NULL, " +
|
||||||
@@ -31,7 +23,6 @@ public class V3__AddConfigTables extends BaseJavaMigration {
|
|||||||
"updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, " +
|
"updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, " +
|
||||||
"INDEX idx_site_id (site_id, deleted)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
|
"INDEX idx_site_id (site_id, deleted)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
|
||||||
|
|
||||||
// 风险规则
|
|
||||||
stmt.execute("CREATE TABLE IF NOT EXISTS risk_rules (" +
|
stmt.execute("CREATE TABLE IF NOT EXISTS risk_rules (" +
|
||||||
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
||||||
"site_type VARCHAR(32) NOT NULL, " +
|
"site_type VARCHAR(32) NOT NULL, " +
|
||||||
@@ -42,6 +33,6 @@ public class V3__AddConfigTables extends BaseJavaMigration {
|
|||||||
"updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, " +
|
"updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, " +
|
||||||
"INDEX idx_site_type (site_type, deleted)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
|
"INDEX idx_site_type (site_type, deleted)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
|
||||||
|
|
||||||
System.out.println("[Flyway V3] Config tables and tags column created");
|
System.out.println("[Flyway V15] tags column + site_pages + risk_rules tables created");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user