Skip to content

Commit

Permalink
Merge pull request #49 from palantirnet/load-db
Browse files Browse the repository at this point in the history
Add a 'load-db' target.
  • Loading branch information
becw authored Jan 18, 2017
2 parents c683695 + 182e2fc commit 58e8689
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,27 @@ Cool! This phing-ism is what powers our environment-specific property layering a

[More info](../tasks/acquia.xml#L32-L59)

### DB Loading

| Property | Default value | What is it? |
|---|---|---|
| `db.load.export_pattern` | `artifacts/*` | Pattern to match gzipped database dump files. |
| `db.load.mysql_command` | `drush sqlc` | Command with which to load stuff into Drupal. |
| `db.load.file` | | Load a specific file rather than one matching the `export_pattern`. |

Example usage:

```
<import file="vendor/palantirnet/the-build/tasks/lib/db.xml" />
<target name="load">
<phingcall target="load-db">
<property name="db.load.export_prefix" value="artifacts/prod-*" />
</phingcall>
</target>
```

[More info](../tasks/lib/db.xml)

----
Copyright 2016 Palantir.net, Inc.
39 changes: 39 additions & 0 deletions tasks/lib/db.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<project name="db" default="status">


<target name="status">
<echo>Hello world.</echo>
</target>


<!-- Target: load-db -->
<target name="load-db" description="Load a database export.">
<property name="db.load.export_pattern" value="artifacts/*" />
<property name="db.load.mysql_command" value="drush sqlc" />

<exec dir="${build.dir}" command="ls ${db.load.export_pattern}.sql.gz | tail -1" outputProperty="db.load.file" />

<if>
<equals arg1="${load.db}" arg2="" />
<then>
<echo>Missing database export at '${db.load.export_pattern}.sql.gz'

Please download a database export to:
${db.load.export_pattern}.sql.gz

Alternatively, you can specify the export file prefix; for example:
vendor/bin/phing [YOUR-TARGET] -Ddb.load.export_pattern=artifacts/prod-*

Or, you can specify the export file directly:
vendor/bin/phing [YOUR-TARGET] -Ddb.load.file=artifacts/my_db.sql.gz
</echo>
<fail message="Missing database export." />
</then>
</if>

<echo>Loading the `${db.load.file}` database...</echo>
<exec dir="${build.dir}" command="gunzip -c ${db.load.file} | ${db.load.mysql_command}" checkreturn="true" logoutput="true" />
</target>


</project>

0 comments on commit 58e8689

Please sign in to comment.