-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
70 lines (54 loc) · 2.55 KB
/
build.xml
File metadata and controls
70 lines (54 loc) · 2.55 KB
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
<?xml version="1.0" ?>
<project name="DBDeployDocker" basedir="." default="migrate">
<!-- Sets the DSTAMP, TSTAMP and TODAY properties -->
<tstamp/>
<!-- Load our configuration -->
<property file="library/deploy.properties" />
<!-- create our migration task -->
<target name="migrate" description="Database Migrations" depends="init.changelog">
<echo msg="Running Migrate" />
<!-- load the dbdeploy task -->
<taskdef name="dbdeploy" classname="phing.tasks.ext.dbdeploy.DbDeployTask"/>
<!-- these two filenames will contain the generated SQL to do the deploy and roll it back-->
<property name="build.dbdeploy.deployfile" value="deploy-${DSTAMP}${TSTAMP}.sql" />
<property name="build.dbdeploy.undofile" value="undo-${DSTAMP}${TSTAMP}.sql" />
<echo msg="Generate Deploy scripts" />
<!-- generate the deployment scripts -->
<dbdeploy
url="mysql:host=${env.HOST};dbname=${env.DB}"
userid="${env.USER}"
password="${env.PASSWORD}"
dir="${delta.dir}"
outputfile="${build.dir}/${build.dbdeploy.deployfile}"
undooutputfile="${build.dir}/${build.dbdeploy.undofile}" />
<!-- execute the SQL - Use mysql command line to avoid trouble with large files or many statements and PDO -->
<echo msg="Import Deploy scripts" />
<exec
command="${progs.mysql} -h${env.HOST} -u${env.USER} -p${env.PASSWORD} --local-infile ${env.DB} < ${build.dbdeploy.deployfile}"
dir="${build.dir}"
checkreturn="true" />
</target>
<!-- Install the changelog Table -->
<target name="init.changelog" description="Install the changelog table" depends="init.db">
<echo msg="Installing Changelog Table" />
<exec
command="${progs.mysql} -h${env.HOST} -u${env.USER} -p${env.PASSWORD} ${env.DB} < library/changelog.sql"
dir="."
checkreturn="true" />
</target>
<!-- Create the host DB if it does not exist -->
<target name="init.db" depends="server.ready">
<echo msg="Creating Database: ${env.DB}" />
<exec command="echo "CREATE DATABASE IF NOT EXISTS ${env.DB};" | mysql -h${env.HOST} -u${env.USER} -p${env.PASSWORD}" />
</target>
<!-- wait for the mysql server to be ready -->
<target name="server.ready" >
<echo msg="Checking DB Server [${env.HOST}]" />
<retry retrycount="10">
<exec command="sleep 2 && mysqladmin ping -h ${env.HOST} -u${env.USER} -p${env.PASSWORD} "
returnproperty="return.code"
checkreturn="true"
/>
</retry>
</target>
</project>