Skip to content

Commit d0f4c17

Browse files
committed
Small changes for db migration
1 parent 140b1e3 commit d0f4c17

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/main/java/no/nav/pto/veilarbportefolje/config/DbConfigPostgres.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,19 @@ public PlatformTransactionManager transactionManager(DataSource dataSource) {
5555
@PostConstruct
5656
@SneakyThrows
5757
public void migrateDb() {
58-
log.info("Starting database migration...");
5958
DataSource dataSource = createDataSource(environmentProperties.getDbUrl());
6059

61-
Flyway.configure()
62-
.validateMigrationNaming(true)
63-
.dataSource(dataSource)
64-
.locations("db/postgres")
65-
.baselineOnMigrate(true)
66-
.load()
67-
.migrate();
60+
if (dataSource != null) {
61+
log.info("Starting database migration...");
62+
Flyway.configure()
63+
.validateMigrationNaming(true)
64+
.dataSource(dataSource)
65+
.locations("db/postgres")
66+
.baselineOnMigrate(true)
67+
.load()
68+
.migrate();
6869

69-
assert dataSource != null;
70-
dataSource.getConnection().close();
70+
dataSource.getConnection().close();
71+
}
7172
}
7273
}

0 commit comments

Comments
 (0)