-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
89 lines (79 loc) · 3.6 KB
/
build.xml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="LiquiBase Enterprise Edition" default="help"
xmlns:liquibase="antlib:liquibase.integration.ant">
<target name="help">
<echo>ant create-database</echo>
<echo>ant migrate-database</echo>
<echo>ant rollback-database</echo>
<echo>ant show-sql</echo>
</target>
<target name="setup-database">
<property file="conf/application.conf"/>
<path id="database.lib.path">
<fileset dir="jars" includes="*.jar"/>
<fileset dir="modules" includes="liquibase*/lib/liquibase-core*.jar"/>
</path>
<taskdef resource="liquibase/integration/ant/antlib.xml" uri="antlib:liquibase.integration.ant">
<classpath refid="database.lib.path"/>
</taskdef>
<echo message="Database URL: ${db.url}"/>
</target>
<target name="unlock-database" depends="setup-database">
<sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.pass}"
classpathref="database.lib.path" onerror="continue">
update databasechangeloglock set locked = 0;
</sql>
</target>
<target name="migrate-database" depends="setup-database">
<property name="dropFirst" value="false"/>
<echo message="Database username: ${db.user}, contexts: ${liquibase.contexts}"/>
<liquibase:updateDatabase
dropFirst="${dropFirst}" classpathref="database.lib.path"
changeLogFile="app/database/changelog.xml"
contexts="${liquibase.contexts}">
<liquibase:database driver="${db.driver}"
url="${db.url}"
user="${db.user}"
password="${db.pass}"/>
<liquibase:changeLogParameters>
<liquibase:changeLogParameter name="db.dblink.accounts" value="${db.dblink.accounts}"/>
<liquibase:changeLogParameter name="db.dblink.payments" value="${db.dblink.payments}"/>
</liquibase:changeLogParameters>
</liquibase:updateDatabase>
</target>
<target name="show-sql" depends="setup-database">
<echo message="Database username: ${db.user}"/>
<java classname="liquibase.integration.commandline.Main" classpathref="database.lib.path" fork="true">
<jvmarg value="-Ddatabase.dblink.accounts=${db.dblink.accounts}"/>
<jvmarg value="-Ddatabase.dblink.payments=${db.dblink.payments}"/>
<arg value="--driver=${db.driver}"/>
<arg value="--changeLogFile=app/database/changelog.xml"/>
<arg value="--url=${db.url}"/>
<arg value="--username=${db.user}"/>
<arg value="--password=${db.pass}"/>
<arg value="--contexts=prod"/>
<arg value="updateSQL"/>
</java>
</target>
<target name="create-database">
<property name="dropFirst" value="true"/>
<antcall target="migrate-database"/>
</target>
<target name="rollback-database" depends="setup-database">
<echo message="Database username: ${db.user}"/>
<property name="count" value="1"/>
<liquibase:rollbackDatabase
classpathref="database.lib.path" rollbackCount="${count}"
changeLogFile="app/database/changelog.xml"
contexts="${liquibase.contexts}">
<liquibase:database driver="${db.driver}"
url="${db.url}"
user="${db.user}"
password="${db.pass}"/>
<liquibase:changeLogParameters>
<liquibase:changeLogParameter name="db.dblink.accounts" value="${db.dblink.accounts}"/>
<liquibase:changeLogParameter name="db.dblink.payments" value="${db.dblink.payments}"/>
</liquibase:changeLogParameters>
</liquibase:rollbackDatabase>
</target>
</project>