generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
liquibase.gradle
53 lines (43 loc) · 1.97 KB
/
liquibase.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
configurations {
liquibase
}
dependencies {
liquibase group: 'org.liquibase.ext', name: 'liquibase-hibernate5', version: 3.8
}
//loading properties file.
Properties liquibaseProps = new Properties()
liquibaseProps.load(new FileInputStream("$projectDir/src/main/resources/liquibase.properties"))
task liquibaseDiffChangelog(type: JavaExec) {
group = "liquibase"
classpath sourceSets.main.runtimeClasspath
classpath configurations.liquibase
main = "liquibase.integration.commandline.Main"
args "--changeLogFile=" + "$projectDir/src/main/resources/db/changelog/db.changelog-diff-" + buildTimestamp() + ".xml"
args "--referenceUrl=hibernate:spring:uk.gov.hmcts.reform.notifications.model?dialect=org.hibernate.dialect.PostgreSQL94Dialect"
args "--username=" + liquibaseProps.getProperty('username')
args "--password=" + liquibaseProps.getProperty('password')
args "--url=" + liquibaseProps.getProperty('url')
args "--driver=" + liquibaseProps.getProperty('driver')
args "diffChangeLog"
}
task migratePostgresDatabase(type: JavaExec) {
group = "liquibase"
classpath sourceSets.main.runtimeClasspath
classpath configurations.liquibase
main = "liquibase.integration.commandline.Main"
systemProperty "liquibase.useDbLock", true
def urlString = project.hasProperty("dburl") ? "jdbc:postgresql://$dburl" : liquibaseProps.getProperty('url')
def user = project.hasProperty("flyway.user") ? "${rootProject.properties['flyway.user']}" : liquibaseProps.getProperty('username')
def password = project.hasProperty("flyway.password") ? "${rootProject.properties['flyway.password']}" : liquibaseProps.getProperty('password')
args "--changeLogFile=./src/main/resources/db/changelog/db.changelog-master.xml"
args "--username=$user"
args "--password=$password"
args "--url=$urlString"
args "--driver=" + liquibaseProps.getProperty('driver')
args "update"
}
def buildTimestamp() {
def date = new Date()
def formattedDate = date.format('yyyyMMdd-HHmm')
return formattedDate
}