Skip to content

Commit 936d65a

Browse files
Generate current model changes into db/changelog/dev (#260)
With this PR the following changes are made: - Also generate a delta DDL sql for current model changes against model v2. - Also deploy current CDS development model as delta DDL sql to Postgres with Liquibase - Ensure that the Postgres testcontainer instance is also restarted to avoid Liquibase issue due to modified changeset context for current dev DDL sql. --------- Co-authored-by: Vladimir Mikhaylenko <[email protected]>
1 parent 8749e58 commit 936d65a

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

srv/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@
168168
<configuration>
169169
<commands>
170170
<command>build --for java</command>
171+
<command>deploy --profile pg --dry --delta-from srv/src/main/resources/db/changelog/v2/model.csn >
172+
srv/src/main/resources/db/changelog/dev/model.sql</command>
173+
<command>deploy --model-only --dry > srv/src/main/resources/db/changelog/dev/model.csn</command>
171174
</commands>
172175
</configuration>
173176
</execution>

srv/src/main/resources/application.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ cds:
2020
---
2121
spring:
2222
config.activate.on-profile: cloud
23+
liquibase.contexts: "!dev"
2324

2425
---
2526
spring:
2627
config.activate.on-profile: default
28+
liquibase.contexts: "dev"
2729
cds:
2830
dataSource:
2931
auto-config.enabled: false
30-
32+
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
!*.sql
2-
!*.json
2+
!*.json
3+
/dev/*.sql
4+
/dev/*.csn
5+
/dev/*.json

srv/src/main/resources/db/changelog/db.changelog-master.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ databaseChangeLog:
1212
changes:
1313
- sqlFile:
1414
dbms: postgresql
15-
path: db/changelog/v2/model.sql
15+
path: db/changelog/v2/model.sql
16+
- changeSet:
17+
id: "development"
18+
author: CAP Java
19+
contextFilter: dev
20+
changes:
21+
- sqlFile:
22+
dbms: postgresql
23+
path: db/changelog/dev/model.sql

srv/src/main/resources/db/changelog/dev/.keep

Whitespace-only changes.

srv/src/test/java/my/bookshop/config/DatabaseConfiguration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
55
import org.springframework.beans.factory.annotation.Value;
6-
import org.springframework.boot.devtools.restart.RestartScope;
76
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
87
import org.springframework.context.annotation.Bean;
98
import org.springframework.context.annotation.Configuration;
@@ -17,7 +16,6 @@ public class DatabaseConfiguration {
1716

1817
@Bean
1918
@ServiceConnection
20-
@RestartScope
2119
PostgreSQLContainer<?> postgresContainer(@Value("${my.bookshop.postgres-image}") String imageName) {
2220
DockerImageName image = DockerImageName.parse(imageName).asCompatibleSubstituteFor(POSTGRES);
2321
return new PostgreSQLContainer<>(image)

0 commit comments

Comments
 (0)