Addad flyway + fixes

This commit is contained in:
2025-02-13 18:54:37 +03:00
parent fbd6f0adfa
commit 5a212f6024
10 changed files with 58 additions and 59 deletions
+5 -22
View File
@@ -2,7 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.4.2'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.flywaydb.flyway' version '10.11.0'
id 'org.flywaydb.flyway' version '11.3.1'
}
group = 'ru.cathub'
@@ -28,7 +28,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-cache'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
implementation 'org.hibernate:hibernate-tools:6.4.4.Final'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-tools
annotationProcessor 'org.hibernate.orm:hibernate-jpamodelgen:6.4.4.Final'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
@@ -52,6 +53,8 @@ dependencies {
// https://mvnrepository.com/artifact/io.hypersistence/hypersistence-utils-hibernate-63
implementation group: 'io.hypersistence', name: 'hypersistence-utils-hibernate-63', version: '3.9.1'
// https://mvnrepository.com/artifact/org.flywaydb/flyway-database-postgresql
runtimeOnly group: 'org.flywaydb', name: 'flyway-database-postgresql', version: '11.3.1'
}
@@ -60,26 +63,6 @@ tasks.named('test') {
useJUnitPlatform()
}
tasks.register('generateMigration', JavaExec) {
dependsOn 'classes'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'org.hibernate.tool.Main'
args = [
'--hbm2ddl-auto', 'update',
'--properties', 'application.properties',
'--output', 'src/main/resources/db/migration/V' + getNextMigrationVersion() + '__auto_generated.sql'
]
}
def getNextMigrationVersion() {
def migrationDir = project.file('src/main/resources/db/migration')
def existing = migrationDir.listFiles()?.collect {
(it.name =~ /V(\d+)__/)[0][1]
}?.max() ?: 0
return String.format("%03d", existing.toInteger() + 1)
}
flyway {
locations = ['classpath:db/migration']