1
當沒有要遷移的遷移時可以防止beforeMigrate回調腳本運行,因爲該模式已經是最新的嗎?在遷移之前防止遷移到最新模式
下面的代碼(在應用程序啓動時執行): -
Flyway flyway = new Flyway();
flyway.setDataSource(url, user, password);
flyway.setLocations(scriptsLocations);
flyway.setPlaceholders(placeHolders);
flyway.setBaselineVersionAsString("7.0");
flyway.setBaselineOnMigrate(true);
flyway.migrate();
根據日誌遷徙路線運行beforeMigrate回調決定架構之前是最新的,並且沒有遷移到運行。
INFO: Flyway 4.0.3 by Boxfuse
INFO: Database: jdbc:oracle:thin:... (Oracle 11.2)
INFO: Successfully validated 8 migrations (execution time 00:00.023s)
INFO: Executing SQL callback: beforeMigrate
INFO: Current version of schema "...": 7.0.7
INFO: Schema "..." is up to date. No migration necessary.
想要beforeMigrate回調僅在需要遷移時運行。