flyway


Prevent beforeMigrate from running on up to date schema


Is it possible to prevent the beforeMigrate callback script from running when there are no migrations to run because the schema is already up to date?
Here's the code (executed on application startup):-
Flyway flyway = new Flyway();
flyway.setDataSource(url, user, password);
flyway.setLocations(scriptsLocations);
flyway.setPlaceholders(placeHolders);
flyway.setBaselineVersionAsString("7.0");
flyway.setBaselineOnMigrate(true);
flyway.migrate();
According to the log Flyway runs the beforeMigrate callback before deciding the schema is up to date and there are no migrations to run.
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.
Would like the beforeMigrate callback to run only when migrations are necessary.
Found a simple solution; use info to determine if there are pending migrations and make the call to migrate conditional based on the result: -
boolean pending = flyway.info().pending().length > 0;
if (pending) {
flyway.migrate();
}

Related Links

Flyway Command line unable to find migrations on filesystem
Can I use only the parser of flyway
Flyway MySQL syntax error
Placeholder replacement not working with flyway test extensions
Several app instances trying to migrate the same database at the same time
Can flyway handle different IDs across databases
Schema in placeholder programmatically
Base directory and schema_version
flyway: db init without maven?
Flyway-1.7: workaround for dealing with branching? (Flyway issue 138)
Retry a flyway failed migration
Can I use numbers in descriptions to force a loading order for SQL files?
Flyway 1.7 migrations transaction
how does flyway lock a postgres schema?
Flyway migrate Oracle PL/SQL dump
Why version counter and not timestamps

Categories

HOME
cntk
answer-set-programming
angular-cli
jsviews
google-tag-manager
avro
mapbox-gl-js
parse-server
vuex
window
equalizer
sql-tuning
r-lavaan
jcl
kadanes-algorithm
aws-cognito
nmf
rhandsontable
i3
bitcoin-testnet
pygooglechart
receipt
geopy
pycparser
modulo
hashcat
boilerplate
liquid-xml
excel-interop
median
lftp
rich-text-editor
sapui
persistent
spring-data-hadoop
iphone-developer-program
selenium-firefoxdriver
ingres
qos
bettercms
createobject
inject
clob
project-online
qt-linguist
handlebars.java
android-recyclerview
application-loader
p-np
textkit
integral
rx-groovy
twitter-rest-api
coypu
google-hadoop
ctrlp
android-search
utf-32
line-numbers
temp-tables
ultrawingrid
dmp
ember-components
csplit
bsp
korma
delphi-xe3
nsmatrix
jqmobi
threadx
gridworld
carddav
zend-lucene
zend-framework-modules
legacy-code
z-machine
coff
for-xml-path
post-redirect-get
hibernate3-maven-plugin
filetime
virtualquery
weborb
self-reference

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App