Skip to content

Commit cbadb48

Browse files
authored
Set up flyway klass api (#283)
* delete flyway schemas - move flyway to klass api * add flyway to klass api * add flyway to klass api * add properties and use adapted sql file for test * use flyway in tests using postgres embedded except apidocumentation test * set nais password for flyway * set nais username for flyway * update flyway version
1 parent 7d26c5f commit cbadb48

File tree

45 files changed

+1201
-590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1201
-590
lines changed

klass-api/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@
7979
<artifactId>postgresql</artifactId>
8080
</dependency>
8181

82+
<!--Flyway-->
83+
<dependency>
84+
<groupId>org.flywaydb</groupId>
85+
<artifactId>flyway-database-postgresql</artifactId>
86+
<version>11.11.0</version>
87+
<scope>runtime</scope>
88+
</dependency>
89+
<dependency>
90+
<groupId>org.flywaydb</groupId>
91+
<artifactId>flyway-core</artifactId>
92+
<version>11.11.1</version>
93+
</dependency>
94+
95+
8296
<!--TOMCAT-->
8397
<dependency>
8498
<groupId>org.springframework.boot</groupId>
@@ -213,6 +227,11 @@
213227
<id>documentation</id>
214228
<build>
215229
<plugins>
230+
<plugin>
231+
<groupId>org.flywaydb</groupId>
232+
<artifactId>flyway-maven-plugin</artifactId>
233+
<version>11.11.0</version>
234+
</plugin>
216235
<plugin>
217236
<groupId>org.apache.maven.plugins</groupId>
218237
<artifactId>maven-surefire-plugin</artifactId>

klass-api/src/main/resources/application-h2-inmemory.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ spring.datasource.username=sa
55
spring.datasource.password=
66

77
spring.flyway.enabled=false
8-
#spring.flyway.locations=classpath:db/postgresql
98

109
spring.jpa.hibernate.ddl-auto=create-drop
1110
spring.jpa.show-sql=true
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
2-
spring.flyway.enabled=false
3-
#spring.flyway.locations=classpath:db/postgresql
42

53
spring.jpa.hibernate.ddl-auto=create-drop
64
spring.jpa.show-sql=true
75

6+
# Flyway
7+
spring.flyway.enabled=true
8+
spring.flyway.locations=classpath:db/migration/test
9+

klass-api/src/main/resources/application-postgres-local.properties

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ spring.datasource.username=klass
44
spring.datasource.password=${POSTGRES_PASSWORD}
55
spring.datasource.driverclassName=org.postgresql.Driver
66
spring.jpa.hibernate.ddl-auto=none
7-
spring.flyway.enabled=false
7+
88
spring.datasource.hikari.connection-test-query=SELECT 1
99
spring.datasource.hikari.validation-timeout=3000
1010
spring.jpa.properties.hibernate.format_sql=true
1111
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
12+
13+
# Flyway
14+
spring.flyway.enabled=true
15+
spring.flyway.url=jdbc:postgresql://${POSTGRES_INSTANCE}:5432/klass
16+
spring.flyway.password=${POSTGRES_PASSWORD}
17+
spring.flyway.user=klass
18+
spring.flyway.locations=classpath:db/migration
19+
# This is for first time running on a database with data, but no flyway schema history table
20+
spring.flyway.baseline-on-migrate=true
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# custom properties used when "postgres" Profile is used
22
spring.datasource.url=${NAIS_DATABASE_KLASS_KLASS_JDBC_URL}
33
spring.jpa.hibernate.ddl-auto=none
4-
spring.flyway.enabled=false
54
spring.datasource.hikari.connection-test-query=SELECT 1
65
spring.datasource.hikari.validation-timeout=3000
76
spring.datasource.hikari.maximum-pool-size=20
87
spring.datasource.hikari.leak-detection-threshold=20000
98
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
9+
10+
# Flyway
11+
spring.flyway.enabled=true
12+
spring.flyway.url=${NAIS_DATABASE_KLASS_KLASS_JDBC_URL}
13+
spring.flyway.password=${NAIS_DATABASE_KLASS_KLASS_PASSWORD}
14+
spring.flyway.user=${NAIS_DATABASE_KLASS_KLASS_USERNAME}
15+
spring.flyway.locations=classpath:db/migration
16+
# This is for first time running on a database with data, but no flyway schema history table
17+
spring.flyway.baseline-on-migrate=true

klass-shared/src/main/resources/db/postgresql/V1__init.sql renamed to klass-api/src/main/resources/db/migration/V1__init.sql

File renamed without changes.

0 commit comments

Comments
 (0)