Skip to content

Commit e25c3c1

Browse files
committed
Issue 368: WIP, test for pending migrations
1 parent 46930eb commit e25c3c1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/FlywayMigrationPlugin.groovy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,26 @@ class FlywayMigrationPlugin implements TerraformEnvironmentStagePlugin, Resettab
2020
withEnv(environmentVariables) {
2121
def command = new FlywayCommand('info')
2222
sh buildFlywayCommand(command)
23+
if (confirmBeforeApply && hasPendingMigration(delegate)) {
24+
sh 'echo Pending migration detected, prompt again'
25+
}
2326
}
2427
}
2528
}
2629

30+
public boolean hasPendingMigration(workflowScript) {
31+
def closure = {
32+
def resultString = sh (
33+
script: 'set +e; grep Pending flyway_output.txt > /dev/null; if [ $? -eq 0 ]; then echo true; else echo false; fi',
34+
returnStdout: true
35+
).trim()
36+
return new Boolean(resultString)
37+
}
38+
39+
closure.delegate = workflowScript
40+
return closure()
41+
}
42+
2743
public Closure flywayMigrateClosure() {
2844
return { innerClosure ->
2945
innerClosure()

0 commit comments

Comments
 (0)