fix: Flyway版本号V3→V15匹配当前Schema版本

This commit is contained in:
mediabot-pt
2026-07-05 21:43:04 +08:00
parent 6fb52758c2
commit a560ade64c

View File

@@ -5,22 +5,14 @@ import org.flywaydb.core.api.migration.Context;
import java.sql.Statement;
/**
* Flyway V3:新增配置表和字段
* - sites 表增加 tags 列
* - site_pages 表
* - risk_rules 表
*/
public class V3__AddConfigTables extends BaseJavaMigration {
public class V15__AddConfigTables extends BaseJavaMigration {
@Override
public void migrate(Context context) throws Exception {
Statement stmt = context.getConnection().createStatement();
// 站点标签
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 (" +
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
"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, " +
"INDEX idx_site_id (site_id, deleted)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
// 风险规则
stmt.execute("CREATE TABLE IF NOT EXISTS risk_rules (" +
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
"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, " +
"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");
}
}