-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
69 lines (58 loc) · 3.08 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
<project name="cphp demo project" default="help" basedir=".">
<property file="./build.properties" />
<target name="help" description="List available targets">
<exec executable="vendor/bin/phing"
passthru="true">
<arg value="-l"/>
</exec>
</target>
<target name="drop-db">
<mkdir dir="${project.basedir}/data/db" />
<echo file="${project.basedir}/data/db/drop.sql">DROP DATABASE IF EXISTS `${db.name}`;</echo>
<pdosqlexec url="mysql:host=${db.host}" userid="${db.username}" password="${db.password}">
<transaction src="./data/db/drop.sql"/>
</pdosqlexec>
<delete file="${project.basedir}/data/db/drop.sql" quiet="true"/>
</target>
<target name="init-db" description="Create Database and Grants">
<mkdir dir="${project.basedir}/data/db" />
<echo file="${project.basedir}/data/db/create.sql">
CREATE DATABASE IF NOT EXISTS ${db.name};
GRANT USAGE ON *.* TO '${db.username}'@'%' IDENTIFIED BY '${db.password}';
GRANT UPDATE,CREATE,REFERENCES,ALTER,LOCK TABLES,CREATE VIEW,CREATE
ROUTINE,TRIGGER,INSERT,DELETE,DROP,INDEX,CREATE TEMPORARY TABLES,EXECUTE,SHOW VIEW,ALTER ROUTINE,SELECT ON
`${db.name}`.* TO '${db.username}'@'%';
</echo>
<pdosqlexec url="mysql:host=${db.host}" userid="${db.username}" password="${db.password}">
<transaction src="${project.basedir}/data/db/create.sql"/>
</pdosqlexec>
<delete file="${project.basedir}/data/db/create.sql" quiet="true"/>
</target>
<target name="reset-db"
description="Drop database and reset data"
depends="drop-db, init-db, db-migration"/>
<target name="link-docroot" description="Link site document root to Apache document root">
<symlink link="${server.docroot}" target="${project.basedir}/public" overwrite="true" />
</target>
<target name="setup-db" description="Setup Database Credentials">
<loadfile property="db.config" file="${project.basedir}/config/autoload/database.local.php.dist">
<filterchain>
<replacetokens>
<token key="db.host" value="${db.host}"/>
<token key="db.username" value="${db.username}"/>
<token key="db.password" value="${db.password}"/>
<token key="db.name" value="${db.name}"/>
</replacetokens>
</filterchain>
</loadfile>
<echo message="${db.config}" file="${project.basedir}/config/autoload/database.local.php"/>
</target>
<target name="db-migration" description="Update the database version">
<exec command="${doctrine.bin} migrations:migrate --no-interaction" passthru="true"/>
<exec command="${doctrine.bin} orm:clear-cache:metadata" passthru="true"/>
<exec command="${doctrine.bin} orm:clear-cache:query" passthru="true"/>
</target>
<target name="init"
description="Setup external dependencies and migrate data"
depends="setup-db, db-migration"/>
</project>