-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.xml
More file actions
executable file
·240 lines (215 loc) · 10.4 KB
/
build.xml
File metadata and controls
executable file
·240 lines (215 loc) · 10.4 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?xml version="1.0"?>
<project name="migrations" default="build" basedir=".">
<property file='build.properties' />
<condition property="build.dns" value='mysql -h${db.host} -u${db.user} -p${db.pass} --protocol=TCP -S ${db.socket} ${db.name}'>
<os family="unix" />
</condition>
<condition property="build.dns" value='mysql -h${db.host} -u${db.user} -p${db.pass} ${db.name}'>
<os family="mac" />
</condition>
<includepath classpath="${phingdir}" />
<!-- Sets the DSTAMP, TSTAMP and TODAY properties -->
<tstamp/>
<target name="build.setdefaultDatabase">
<echo msg="Making sure MySQL has default databases set up."/>
<exec command="pwd" passthru="true"/>
<property name="mysql.setup" value='mysql -h${db.host} -u${root.user} -p${root.password}' />
<exec
command="${mysql.setup} < deltas/mysql/${root.scriptZero}"
dir="${build.dir}"
passthru="true"
checkreturn="true"
/>
<exec
command="${mysql.setup} < deltas/mysql/${root.scriptOne}"
dir="${build.dir}"
passthru="true"
checkreturn="true"
/>
</target>
<target name="build.cleanup">
<echo msg="Trying to clean up checkout dir" />
<delete includeemptydirs="false">
<fileset dir="${build.dir}/deltas/seeds/mysql" defaultexcludes='false'>
<include name="**/**"/>
</fileset>
<fileset dir="${build.dir}/deltas/seeds/sqlite" defaultexcludes='false'>
<include name="**/**"/>
</fileset>
<fileset dir="${build.dir}/deploy/mysql/" defaultexcludes='false'>
<include name="**/**"/>
</fileset>
<fileset dir="${build.dir}/deploy/sqlite/" defaultexcludes='false'>
<include name="**/**"/>
</fileset>
<fileset dir="${build.dir}/undo/mysql/" defaultexcludes='false'>
<include name="**/**"/>
</fileset>
<fileset dir="${build.dir}/undo/sqlite/" defaultexcludes='false'>
<include name="**/**"/>
</fileset>
<fileset dir="${errorlog}/phing/" defaultexcludes='false'>
<include name="**/**"/>
</fileset>
</delete>
</target>
<target name="build.generateCleanupSQL">
<echo message="executing php commands at ${faker}" />
<exec dir="${faker}" command="php 99-phingClean.php" escape="false" />
<echo message="Generated cleanup SQL." />
<echo message="Executing cleanup." />
<exec
command="${build.dns} < ${faker}/reversion/revertMySQL.sql"
passthru="true"
checkreturn="true"
/>
<exec
command="sqlite3 ${build.dir}/sqlite/widgets.sqlite < ${faker}/reversion/revertSQLite.sql"
passthru="true"
checkreturn="true"
/>
<echo message="${build.dns} < revertMysql.sql" />
</target>
<target name="build.migrate" description="Database Migrations">
<tstamp/>
<echo message="${build.dns} is the fully qualified URL." />
<!-- load the dbdeploy task -->
<taskdef name="dbdeploy" classname="phing.tasks.ext.dbdeploy.DbDeployTask"/>
<echo message="${build.dir} is the build directory" />
<!-- these files will contain the generated SQL to do the deploy and roll it back-->
<property name="build.dbdeploy.sqlite.deployfile" value="${build.dir}/deploy/sqlite/deploy-${DSTAMP}${TSTAMP}.sql" />
<property name="build.dbdeploy.sqlite.undofile" value="${build.dir}/undo/sqlite/undo-${DSTAMP}${TSTAMP}.sql" />
<property name="build.dbdeploy.mysql.deployfile" value="${build.dir}/deploy/mysql/deploy-${DSTAMP}${TSTAMP}.sql" />
<property name="build.dbdeploy.mysql.undofile" value="${build.dir}/undo/mysql/undo-${DSTAMP}${TSTAMP}.sql" />
<!-- generate the deployment scripts -->
<dbdeploy
url="mysql:host=localhost;dbname=widgets"
userid="${db.user}"
password="${db.pass}"
dir="${build.dir}/deltas/mysql"
outputfile="${build.dbdeploy.mysql.deployfile}"
undooutputfile="${build.dbdeploy.mysql.undofile}" />
<dbdeploy
url="sqlite:${build.dir}/sqlite/widgets.sqlite"
dir="${build.dir}/deltas/sqlite"
outputfile="${build.dbdeploy.sqlite.deployfile}"
undooutputfile="${build.dbdeploy.sqlite.undofile}"
/>
<echo message="${build.dns} < ${build.dbdeploy.mysql.deployfile}" />
<!-- Execute the SQL to push it into the MySQL Database. -->
<exec
command="${build.dns} < ${build.dbdeploy.mysql.deployfile}"
passthru="true"
checkreturn="true"
error="${errorlog}/phing/mysql-deploy-error-${DSTAMP}${TSTAMP}.log"
/>
<echo message="sqlite:${build.dir}/sqlite/widgets.sqlite
executes command sqlite3 widgets.sqlite < ${build.dbdeploy.sqlite.deployfile}" />
<!-- Execute the SQL to push into the SQLite Database. -->
<exec
command="sqlite3 ${build.dir}/sqlite/widgets.sqlite < ${build.dbdeploy.sqlite.deployfile}"
passthru="true"
checkreturn="true"
error="${errorlog}/phing/sqlite-deploy-error-${DSTAMP}${TSTAMP}.log"
/>
</target>
<target name="build.generateSeeds">
<echo message="executing php commands at ${faker}" />
<exec dir="${faker}"
checkreturn="true"
error="${errorlog}/phing/fakeCompanies.log"
command="php 2-fakeCompanies.php" escape="false" />
<echo message="Built fake companies." />
<exec dir="${faker}"
checkreturn="true"
error="${errorlog}/phing/fakeEmployees.log"
command="php 3-fakeEmployees.php" escape="false" />
<echo message="Built fake employees." />
<exec dir="${faker}"
checkreturn="true"
error="${errorlog}/phing/fakeGroups.log"
command="php 4-fakeGroups.php" escape="false" />
<echo message="Built fake groups." />
<exec dir="${faker}"
checkreturn="true"
error="${errorlog}/phing/fakeCustomers.log"
command="php 5-fakeCustomers.php" escape="false" />
<echo message="Built fake customers." />
<exec dir="${faker}"
checkreturn="true"
error="${errorlog}/phing/fakeOrders.log"
command="sudo php 6-fakeOrders.php" escape="false" />
<echo message="Built fake orders." />
<exec dir="${faker}"
checkreturn="true"
error="${errorlog}/phing/fakeCompanyToGroups.log"
command="php 7-fakeCompanyToGroups.php" escape="false" />
<echo message="Built fake Company To Groups." />
<exec dir="${faker}"
checkreturn="true"
error="${errorlog}/phing/fakeCustomersToOrders.log"
command="php 8-fakeCustomersToOrders.php" escape="false" />
<echo message="Built fake Customers to Orders." />
<exec dir="${faker}"
checkreturn="true"
error="${errorlog}/phing/fakeGroupsToOrders.log"
command="php 9-fakeGroupsToOrders.php" escape="false" />
<echo message="Built fake Groups To Orders." />
<exec dir="${faker}"
checkreturn="true"
error="${errorlog}/phing/fakeEmployeesToGroups.log"
command="php 10-fakeEmployeesToGroups.php" escape="false" />
<echo message="Built fake Employees to Groups." />
</target>
<target name="build.seed" description="Database Seed Migrations">
<tstamp/>
<echo message="${build.dns} is the fully qualified URL." />
<!-- load the dbdeploy task -->
<taskdef name="dbdeploy" classname="phing.tasks.ext.dbdeploy.DbDeployTask"/>
<echo message="${build.dir} is the build directory" />
<!-- these files will contain the generated SQL to do the deploy and roll it back-->
<property name="build.dbdeploy.sqlite.deployfile" value="${build.dir}/deploy/sqlite/seedDeploy-${DSTAMP}${TSTAMP}.sql" />
<property name="build.dbdeploy.sqlite.undofile" value="${build.dir}/undo/sqlite/seedUndo-${DSTAMP}${TSTAMP}.sql" />
<property name="build.dbdeploy.mysql.deployfile" value="${build.dir}/deploy/mysql/seedDeploy-${DSTAMP}${TSTAMP}.sql" />
<property name="build.dbdeploy.mysql.undofile" value="${build.dir}/undo/mysql/seedUndo-${DSTAMP}${TSTAMP}.sql" />
<!-- generate the deployment scripts -->
<dbdeploy
url="mysql:host=localhost;dbname=widgets"
userid="${db.user}"
password="${db.pass}"
dir="${build.dir}/deltas/seeds/mysql"
outputfile="${build.dbdeploy.mysql.deployfile}"
undooutputfile="${build.dbdeploy.mysql.undofile}" />
<dbdeploy
url="sqlite:${build.dir}/sqlite/widgets.sqlite"
dir="${build.dir}/deltas/seeds/sqlite"
outputfile="${build.dbdeploy.sqlite.deployfile}"
undooutputfile="${build.dbdeploy.sqlite.undofile}"
/>
<echo message="${build.dns} < ${build.dbdeploy.mysql.deployfile}" />
<!-- Execute the SQL to push it into the MySQL Database. -->
<exec
command="${build.dns} < ${build.dbdeploy.mysql.deployfile}"
passthru="true"
checkreturn="true"
error="${errorlog}/phing/mysqlSeed-deploy-error-${DSTAMP}${TSTAMP}.log"
/>
<echo message="sqlite:${build.dir}/sqlite/widgets.sqlite
executes command sqlite3 widgets.sqlite < ${build.dbdeploy.sqlite.deployfile}" />
<!-- Execute the SQL to push into the SQLite Database. -->
<exec
command="sqlite3 ${build.dir}/sqlite/widgets.sqlite < ${build.dbdeploy.sqlite.deployfile}"
passthru="true"
checkreturn="true"
dir=""
error="${errorlog}/phing/sqlite-deploy-error-${DSTAMP}${TSTAMP}.log"
/>
</target>
<target name="build" depends="build.cleanup,
build.setdefaultDatabase,
build.generateCleanupSQL,
build.migrate,
build.generateSeeds,
build.seed,
build.cleanup" />
</project>