Skip to content

Commit fbeee79

Browse files
committed
Flyway changes
- flyway: must favor existing datasource and should not create a new database connection fix jooby-project#1034 - flyway 5.0.7 fix jooby-project#1035
1 parent dceb4f0 commit fbeee79

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

doc/doc/flyway/flyway.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# flyway
22

3-
Evolve your Database Schema easily and reliably across all your instances.
3+
Evolve your database schema easily and reliably across all your instances.
44

5-
This module run {{flyway}} on startup and apply database migration.
5+
This module run {{flyway}} on startup and apply database migrations.
66

7-
> NOTE: This module depends on [jdbc](https://github.com/jooby-project/jooby/tree/master/jooby-jdbc) module so all the services provided by the [jdbc](https://github.com/jooby-project/jooby/tree/master/jooby-jdbc) module.
7+
> NOTE: This module depends on [jdbc](https://github.com/jooby-project/jooby/tree/master/jooby-jdbc) module to acquire a database connection.
88
99
## dependency
1010

@@ -60,7 +60,7 @@ flyway.run = [clean, migrate, validate, info]
6060
## configuration
6161

6262
Configuration is done via ```application.conf``` under the ```flyway.*``` path.
63-
There are some defaults setting that you can see in the appendix.
63+
There are some defaults setting that you can see in the appendix section.
6464

6565

6666
For more information, please visit the {{flyway}} site.

modules/jooby-flyway/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@
4444
<artifactId>flyway-core</artifactId>
4545
</dependency>
4646

47-
<!-- Hibernate -->
48-
<dependency>
49-
<groupId>org.hibernate</groupId>
50-
<artifactId>hibernate-entitymanager</artifactId>
51-
<optional>true</optional>
52-
</dependency>
53-
5447
<!-- Test dependencies -->
5548
<dependency>
5649
<groupId>org.jooby</groupId>

modules/jooby-flyway/src/main/java/org/jooby/flyway/Flywaydb.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -203,26 +203,23 @@
203203
*/
204204
package org.jooby.flyway;
205205

206+
import com.google.inject.Binder;
206207
import com.google.inject.Key;
207208
import com.google.inject.name.Names;
209+
import com.typesafe.config.Config;
210+
import com.typesafe.config.ConfigFactory;
208211
import static java.util.Objects.requireNonNull;
209-
210-
import java.util.ArrayList;
211-
import java.util.List;
212-
import java.util.NoSuchElementException;
213-
import java.util.Properties;
214-
import java.util.stream.Collectors;
215-
216212
import org.flywaydb.core.Flyway;
217213
import org.jooby.Env;
218214
import org.jooby.Jooby.Module;
219-
220-
import com.google.inject.Binder;
221-
import com.typesafe.config.Config;
222-
import com.typesafe.config.ConfigFactory;
223215
import org.jooby.funzy.Try;
224216

225217
import javax.sql.DataSource;
218+
import java.util.ArrayList;
219+
import java.util.List;
220+
import java.util.NoSuchElementException;
221+
import java.util.Properties;
222+
import java.util.stream.Collectors;
226223

227224
/**
228225
* <h1>flyway module</h1>
@@ -359,8 +356,8 @@ public Flywaydb() {
359356

360357
@Override
361358
public void configure(final Env env, final Config conf, final Binder binder) {
362-
Config $base = conf.getConfig("flyway");
363-
Config $flyway = Try.apply(() -> conf.getConfig(name).withFallback($base))
359+
Config $base = conf.getConfig("flyway").withoutPath(name);
360+
Config $flyway = Try.apply(() -> conf.getConfig("flyway." + name).withFallback($base))
364361
.orElse($base);
365362

366363
Flyway flyway = new Flyway();
@@ -376,9 +373,8 @@ public void configure(final Env env, final Config conf, final Binder binder) {
376373
.generate(Flyway.class, name, key -> binder.bind(key).toInstance(flyway));
377374
// run
378375
Iterable<Command> cmds = commands($flyway);
379-
env.onStart(registry -> {
380-
cmds.forEach(cmd -> cmd.run(flyway));
381-
});
376+
// eager initialization
377+
cmds.forEach(cmd -> cmd.run(flyway));
382378
}
383379

384380
@Override

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3031,7 +3031,7 @@ org.eclipse.jdt.apt.processorOptions/defaultOverwrite=true
30313031
<commons-email.version>1.4</commons-email.version>
30323032
<jongo.version>1.3.0</jongo.version>
30333033
<bson4jackson.version>2.9.0</bson4jackson.version>
3034-
<flyway.version>4.2.0</flyway.version>
3034+
<flyway.version>5.0.7</flyway.version>
30353035
<hazelcast.version>3.9.2</hazelcast.version>
30363036
<less4j.version>1.13.0</less4j.version>
30373037
<ebean.version>10.1.7</ebean.version>

0 commit comments

Comments
 (0)