플라이 웨이는 mysql 데이터베이스의 플라이 웨이 기본 설정에 따라 "schema_version table"을 생성하기위한 기본 스토리지 엔진으로 INNODB를 사용합니다. MyISAM에 기본 저장소 엔진을 설정할 수 있습니까? 나는 flyway의 항아리를 열고 코드베이스에서 변경하려고했습니다. 나는 또한 schema_version 테이블을 생성하는 .sql 파일을 발견했다. 그러나 그 파일을 바꾸고 항아리를 다시 포장 한 후에 나는 플라이 웨이를 실행할 수 없었습니다. 구성 변경이 있습니까 ??? 여기서 나는 그것을 매개 변수로 바꿀 수있다. flyway 커뮤니티 버전 4.0.3을 사용 중입니다.플라이 웨이의 기본 스토리지 엔진을 변경하는 방법
-1
A
답변
0
가능한 경우 이동 경로 소스를 수정하지 않는 것이 좋습니다.
이동 경로를 만든 후 테이블 엔진을 간단히 변경할 수 있습니까? 이것이 가능하지 않다면, 플라이 웨이를 사용하기 전에베이스 라인을 효과적으로 가로 챌 schema_version 테이블을 직접 만들 수 있습니다.
0
나는 정확히 같은 문제가있었습니다. 내 고객이 InnoDB 엔진을 사용 중지했습니다. 이동 경로는 엔진을 사용자 정의 할 수 없습니다. 하드 코드 :
그래서 난 내 자신이 단계를 실행했다. 그것은 많은 일이 아닙니다 :private static void baselineWithDefaultStorageEngine(Flyway flyway) {
try (Connection con = flyway.getDataSource().getConnection()) {
if (!versionTableExisting(con, flyway)) {
createVersionTable(con);
setBaseline(con);
}
} catch (SQLException e) {
throw new RuntimeException("Konnte Flyway Baseline für " + flyway.getDataSource() + " nicht erstellen.", e);
}
}
private static void createVersionTable(Connection con) throws SQLException {
try(PreparedStatement stmt = con.prepareStatement("CREATE TABLE flyway_schema_history (" +
"`installed_rank` INT NOT NULL, " +
"`version` VARCHAR(50), " +
"`description` VARCHAR(200) NOT NULL, " +
"`type` VARCHAR(20) NOT NULL, " +
"`script` VARCHAR(1000) NOT NULL, " +
"`checksum` INT, " +
"`installed_by` VARCHAR(100) NOT NULL, " +
"`installed_on` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, " +
"`execution_time` INT NOT NULL, " +
"`success` BOOL NOT NULL, " +
"CONSTRAINT `flyway_schema_history_pk` PRIMARY KEY (`installed_rank`), " +
"INDEX `flyway_schema_history_s_idx` (`success`) " +
");")) {
stmt.execute();
}
}
private static void setBaseline(Connection con) throws SQLException {
try (PreparedStatement stmt = con.prepareStatement("INSERT INTO `flyway_schema_history` " +
"(`installed_rank`, `version`, `description`, `type`, `script`, `installed_by`, `execution_time`, `success`) VALUES " +
"(?, ?, ?, ?, ?, ?, ?, ?)")) {
stmt.setInt(1, 1);
stmt.setInt(2, 1);
stmt.setString(3, "<< Flyway Baseline >>");
stmt.setString(4, "BASELINE");
stmt.setString(5, "<< Flyway Baseline >>");
stmt.setString(6, "root");
stmt.setInt(7, 0);
stmt.setInt(8, 1);
stmt.execute();
}
}
private static boolean versionTableExisting(Connection con, Flyway flyway) throws SQLException {
try (PreparedStatement stmt = con.prepareStatement("show tables like 'flyway_schema_history'")) {
try (ResultSet resultSet = stmt.executeQuery()) {
return resultSet.next();
}
}
}