| | 25 | |
|---|
| | 26 | <h2><a name="DbDeployTask"></a>DbDeployTask</h2> |
|---|
| | 27 | <p>The <em>DbDeployTask</em> creates .sql files for making revisions to a database, based on dbdeploy conventions centering around a changelog table in the database. See <a href="http://dbdeploy.com/documentation/getting-started/rules-for-using-dbdeploy/">rules for using dbdeploy</a> for more information. You will need a changelog table like so:</p> |
|---|
| | 28 | |
|---|
| | 29 | <pre>CREATE TABLE changelog ( |
|---|
| | 30 | change_number BIGINT NOT NULL, |
|---|
| | 31 | delta_set VARCHAR(10) NOT NULL, |
|---|
| | 32 | start_dt TIMESTAMP NOT NULL, |
|---|
| | 33 | complete_dt TIMESTAMP NULL, |
|---|
| | 34 | applied_by VARCHAR(100) NOT NULL, |
|---|
| | 35 | description VARCHAR(500) NOT NULL |
|---|
| | 36 | )</pre> |
|---|
| | 37 | |
|---|
| | 38 | <h3>Example</h3> |
|---|
| | 39 | <pre> |
|---|
| | 40 | <taskdef name="dbdeploy" classname="phing.tasks.ext.dbdeploy.DbDeployTask"/> |
|---|
| | 41 | |
|---|
| | 42 | <dbdeploy |
|---|
| | 43 | url="sqlite:${project.basedir}/data/db.sqlite"> |
|---|
| | 44 | userid="dbdeploy" |
|---|
| | 45 | password="dbdeploy" |
|---|
| | 46 | dir="${project.basedir}/data/dbdeploy/deltas" |
|---|
| | 47 | /> |
|---|
| | 48 | </pre> |
|---|
| | 49 | |
|---|
| | 50 | <p>The above example uses a sqlite database and delta scripts located in dbdeploy/deltas in the project base dir.</p> |
|---|
| | 51 | |
|---|
| | 52 | <h3>Attributes</h3> |
|---|
| | 53 | <table> |
|---|
| | 54 | <thead> |
|---|
| | 55 | <tr> |
|---|
| | 56 | <th>Name</th> |
|---|
| | 57 | <th>Type</th> |
|---|
| | 58 | <th>Description</th> |
|---|
| | 59 | <th>Default</th> |
|---|
| | 60 | <th>Required</th> |
|---|
| | 61 | </tr> |
|---|
| | 62 | </thead> |
|---|
| | 63 | <tbody> |
|---|
| | 64 | <tr> |
|---|
| | 65 | <td>url</td> |
|---|
| | 66 | <td>String</td> |
|---|
| | 67 | <td>PDO connection url</td> |
|---|
| | 68 | <td>n/a</td> |
|---|
| | 69 | <td>Yes</td> |
|---|
| | 70 | </tr> |
|---|
| | 71 | <tr> |
|---|
| | 72 | <td>userid</td> |
|---|
| | 73 | <td>String</td> |
|---|
| | 74 | <td>DB userid to use for accessing the changelog table</td> |
|---|
| | 75 | <td>none</td> |
|---|
| | 76 | <td>As required by db</td> |
|---|
| | 77 | </tr> |
|---|
| | 78 | <tr> |
|---|
| | 79 | <td>password</td> |
|---|
| | 80 | <td>String</td> |
|---|
| | 81 | <td>DB password to use for accessing the changelog table</td> |
|---|
| | 82 | <td>none</td> |
|---|
| | 83 | <td>As required by db</td> |
|---|
| | 84 | </tr> |
|---|
| | 85 | <tr> |
|---|
| | 86 | <td>dir</td> |
|---|
| | 87 | <td>String</td> |
|---|
| | 88 | <td>Directory containing dbdeploy delta scripts</td> |
|---|
| | 89 | <td>none</td> |
|---|
| | 90 | <td>Yes</td> |
|---|
| | 91 | </tr> |
|---|
| | 92 | <tr> |
|---|
| | 93 | <td>outputfile</td> |
|---|
| | 94 | <td>String</td> |
|---|
| | 95 | <td>Filename in which deployment SQL will be generated</td> |
|---|
| | 96 | <td>dbdeploy_deploy.sql</td> |
|---|
| | 97 | <td>No</td> |
|---|
| | 98 | </tr> |
|---|
| | 99 | <tr> |
|---|
| | 100 | <td>undooutputfile</td> |
|---|
| | 101 | <td>String</td> |
|---|
| | 102 | <td>Filename in which undo SQL will be generated</td> |
|---|
| | 103 | <td>dbdeploy_undo.sql</td> |
|---|
| | 104 | <td>No</td> |
|---|
| | 105 | </tr> |
|---|
| | 106 | <tr> |
|---|
| | 107 | <td>deltaset</td> |
|---|
| | 108 | <td>String</td> |
|---|
| | 109 | <td>deltaset to check within db</td> |
|---|
| | 110 | <td>Main</td> |
|---|
| | 111 | <td>No</td> |
|---|
| | 112 | </tr> |
|---|
| | 113 | <tr> |
|---|
| | 114 | <td>lastchangetoapply</td> |
|---|
| | 115 | <td>Integer</td> |
|---|
| | 116 | <td>Highest-numbered delta script to apply to db</td> |
|---|
| | 117 | <td>999</td> |
|---|
| | 118 | <td>No</td> |
|---|
| | 119 | </tr> |
|---|
| | 120 | </tbody> |
|---|
| | 121 | </table> |
|---|