Skip to content

Commit

Permalink
Automated Liquibase diff generation from hibernate schema changes in …
Browse files Browse the repository at this point in the history
…development (#137)

Co-authored-by: Felix T.J. Dietrich <[email protected]>
Co-authored-by: Felix T.J. Dietrich <[email protected]>
  • Loading branch information
3 people authored Nov 6, 2024
1 parent 37ef715 commit 9edf554
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/generate-application-server-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
distribution: 'temurin'
java-version: '21'

- name: Set up directories
working-directory: server/application-server
run: |
mkdir -p ./keycloak-data
chmod -R 755 ./keycloak-data
- name: Install dependencies
run: npm install

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"generate:api:intelligence-service": "npm run generate:api:intelligence-service:clean && npm run generate:api:intelligence-service-specs && npm run generate:api:intelligence-service-client",
"generate:api": "npm run generate:api:intelligence-service && npm run generate:api:application-server",
"prettier:java:check": "prettier --check server/application-server/src/**/*.java",
"prettier:java:write": "prettier --write server/application-server/src/**/*.java"
"prettier:java:write": "prettier --write server/application-server/src/**/*.java",
"db:changelog:diff": "cd server/application-server && docker compose up -d postgres && mvn liquibase:diff && docker compose down postgres"
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "2.13.5",
Expand Down
6 changes: 5 additions & 1 deletion server/application-server/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ services:
ports:
- '8081:8080'
volumes:
- keycloak-data:/opt/keycloak/data/
- ./keycloak-hephaestus-realm-example-config.json:/opt/keycloak/data/import/hephaestus-realm.json
networks:
- app-network

networks:
app-network:
driver: bridge
driver: bridge

volumes:
keycloak-data:
48 changes: 48 additions & 0 deletions server/application-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate6</artifactId>
<version>4.27.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
Expand Down Expand Up @@ -265,6 +270,49 @@
<outputDir>.</outputDir>
</configuration>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.27.0</version>
<configuration>
<changeLogFile>db/master.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/db/changelog_new.xml</diffChangeLogFile>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432/hephaestus</url>
<username>root</username>
<password>root</password>
<!-- Hibernate URL for reference schema using the Hibernate 6 dialect -->
<referenceUrl>hibernate:spring:de.tum.in.www1.hephaestus?dialect=org.hibernate.dialect.PostgreSQLDialect
&amp;hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
&amp;hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
</referenceUrl>
<!-- Enable detailed logging output -->
<verbose>true</verbose>
</configuration>
<dependencies>
<!-- Plugin-specific dependency for liquibase-hibernate6 -->
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate6</artifactId>
<version>4.27.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>3.3.3</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ spring:
password: ${DATABASE_PASSWORD}
jpa:
hibernate:
# TODO: Change to none and use liquibase
ddl-auto: update
ddl-auto: none

security:
oauth2:
Expand Down
Loading

0 comments on commit 9edf554

Please sign in to comment.