C.7 DbDeployTask

The DbDeployTask creates .sql files for making revisions to a database, based on dbdeploy conventions centering around a changelog table in the database. See rules for using dbdeploy for more information. You will need a changelog table like so:

Table C.8: Attributes

NameTypeDescriptionDefaultRequired
urlStringPDO connection urln/aYes
useridStringDB userid to use for accessing the changelog table.noneAs required by db
passwordStringDB password to use for accessing the changelog table.noneAs required by db
dirStringDirectory containing dbdeploy delta scripts.noneYes
outputfileStringFilename in which deployment SQL will be generated.dbdeploy_deploy.sqlNo
undooutputfileStringFilename in which undo SQL will be generated.dbdeploy_undo.sqlNo
deltasetStringdeltaset to check within db.MainNo
lastchangetoapplyIntegerHighest-numbered delta script to apply to db.999No
appliedByStringValue of the 'applied_by' column for each entry in the changelog table.dbdeployNo
checkallBooleanFalse means dbdeploy will only apply patches that have a higher number than the last patchnumber that was applied True means dbdeploy will apply all changes that aren't applied already (in ascending order).falseNo

C.7.1 Example

CREATE TABLE changelog (
  change_number BIGINT NOT NULL,
  delta_set VARCHAR(10) NOT NULL,
  start_dt TIMESTAMP NOT NULL,
  complete_dt TIMESTAMP NULL,
  applied_by VARCHAR(100) NOT NULL,
  description VARCHAR(500) NOT NULL
)
<dbdeploy
  url="sqlite:${project.basedir}/data/db.sqlite"
  userid="dbdeploy"
  password="dbdeploy"
  dir="${project.basedir}/data/dbdeploy/deltas"
/>

The above example uses a sqlite database and delta scripts located in dbdeploy/deltas in the project base dir.