fix: V15迁移改为FlywayConfig直接执行SQL避免扫描问题
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
package com.par.core.db.migration;
|
||||
|
||||
import org.flywaydb.core.api.migration.BaseJavaMigration;
|
||||
import org.flywaydb.core.api.migration.Context;
|
||||
|
||||
import java.sql.Statement;
|
||||
|
||||
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, " +
|
||||
"version VARCHAR(20) NOT NULL DEFAULT '1.0.0', " +
|
||||
"entries_json LONGTEXT NOT NULL, " +
|
||||
"deleted TINYINT NOT NULL DEFAULT 0, " +
|
||||
"created_at DATETIME NOT NULL DEFAULT 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");
|
||||
|
||||
stmt.execute("CREATE TABLE IF NOT EXISTS risk_rules (" +
|
||||
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
||||
"site_type VARCHAR(32) NOT NULL, " +
|
||||
"version INT NOT NULL DEFAULT 1, " +
|
||||
"rules_json LONGTEXT NOT NULL, " +
|
||||
"deleted TINYINT NOT NULL DEFAULT 0, " +
|
||||
"created_at DATETIME NOT NULL DEFAULT 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");
|
||||
|
||||
System.out.println("[Flyway V15] tags column + site_pages + risk_rules tables created");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user