tasks/ext/dbdeploy/DbDeployTask.php
Generate SQL script for db using dbdeploy schema version table and delta scripts
- Author
- Luke Crouch at SourceForge (http://sourceforge.net)
- Package
- phing.tasks.ext.dbdeploy
- Version
- $Id$
\DbDeployTask
Generate SQL script for db using dbdeploy schema version table and delta scripts
- Parent(s)
- \Task < \ProjectComponent
- Author
- Luke Crouch at SourceForge (http://sourceforge.net)
- Copyright
- 2001,2002 THYRELL. All rights reserved
- Version
- $Id$
Properties


string
$TABLE_NAME= ''changelog''
The tablename to use from the database for storing all changes This cannot be changed
'changelog'
Details- Type
- string


array
$appliedChangeNumbers= 'array()'
Array with all change numbers that are applied already
array()
Details- Type
- array


int
$checkall= 'false'
Checkall attribute False 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)
false
Details- Type
- int


object
$dbmsSyntax= 'null'
Contains the object for the DBMS that is used
null
Details- Type
- object


int
$lastChangeToApply= '999'
The number of the last change to apply
999
Details- Type
- int


string
$outputFile= ''dbdeploy_deploy.sql''
Output file for performing all database patches of this deployment Contains all the SQL statements that need to be executed
'dbdeploy_deploy.sql'
Details- Type
- string


\Project
$project= 'null'
Holds a reference to the project that a project component (a task, a target, etc.) belongs to
A reference to the current project instanceInherited from: \ProjectComponent::$$project\Task::$$projectnull
Details- Type
- \Project
- Inherited_from
- \ProjectComponent::$$project
- Inherited_from
- \Task::$$project


string
$undoOutputFile= ''dbdeploy_undo.sql''
Outputfile for undoing the database patches of this deployment Contains all the SQL statements that need to be executed
'dbdeploy_undo.sql'
Details- Type
- string
Methods


createOutputFile(
string $file, bool $undo
=
false
)
:
void
Generate the sql for doing/undoing the deployment and write it to a file
Name | Type | Description |
---|---|---|
$file | string | |
$undo | bool |


fileNeedsToBeRead(
int $fileChangeNumber, string $lastChangeAppliedInDb
)
:
bool
Determine if this patch file need to be deployed (using fileChangeNumber, lastChangeAppliedInDb and $this->checkall)
Name | Type | Description |
---|---|---|
$fileChangeNumber | int | |
$lastChangeAppliedInDb | string |
Type | Description |
---|---|
bool | True or false if patch file needs to be deployed |


generateSql(
bool $undo
=
false
)
:
string
Generate the sql for doing/undoing this deployment
Name | Type | Description |
---|---|---|
$undo | bool |
Type | Description |
---|---|
string | The sql |


getAppliedChangeNumbers(
)
:
array
Get the numbers of all the patches that are already applied according to the changelog table in the database
Type | Description |
---|---|
array |


getDeltasFilesArray(
)
:
array
Get a list of all the patch files in the patch file directory
Type | Description |
---|---|
array |


getLastChangeAppliedInDb(
)
:
int | mixed
Get the number of the last patch applied to the database
Type | Description |
---|---|
int | mixed | The highest patch number that is applied in the db |


getLocation(
)
:
\Location
Returns the location within the buildfile this task occurs. Used by {@link BuildException} to give detailed error messages.
Inherited from: \Task::getLocation()Type | Description |
---|---|
\Location | The location object describing the position of this task within the buildfile. |


getProject(
)
:
\Project
Returns a reference to current project
Inherited from: \ProjectComponent::getProject()\Task::getProject()Type | Description |
---|---|
\Project | Reference to current porject object |


getRuntimeConfigurableWrapper(
)
:
\RuntimeConfigurable
Returns the wrapper object for runtime configuration
Inherited from: \Task::getRuntimeConfigurableWrapper()Type | Description |
---|---|
\RuntimeConfigurable | The wrapper object used by this task |


getTaskType(
)
:
string
Returns the name of the task under which it was invoked, usually the XML tagname
Inherited from: \Task::getTaskType()Type | Description |
---|---|
string | The type of this task (XML Tag) |


init(
)
:
void
Should throw a BuildException if something goes wrong with the build
This is abstract here, but may not be overloaded by subclasses.
Exception | Description |
---|---|
\BuildException |


log(
string $msg, integer $level
=
Project::MSG_INFO
)
:
void
Name | Type | Description |
---|---|---|
$msg | string | The message to log |
$level | integer | The priority of the message |
- See
- \BuildEvent
- See
- \BuildListener


main(
)
:
void
The main function for the task
Should throw a BuildException if someting goes wrong with the build
This is abstract here. Must be overloaded by real tasks.
Exception | Description |
---|---|
\BuildException |


maybeConfigure(
)
:
void
Configure this task if it hasn't been done already.
Inherited from: \Task::maybeConfigure()

setCheckAll(
bool $checkall
)
:
void
Set the checkall property
Name | Type | Description |
---|---|---|
$checkall | bool |


setDeltaSet(
string $deltaSet
)
:
void
Set the deltaset property
Name | Type | Description |
---|---|---|
$deltaSet | string |


setDescription(
string $desc
)
:
void
Name | Type | Description |
---|---|---|
$desc | string | The text describing the task |


setDir(
string $dir
)
:
void
Set the directory where to find the patchfiles
Name | Type | Description |
---|---|---|
$dir | string |


setLastChangeToApply(
int $lastChangeToApply
)
:
void
Set the lastchangetoapply property
Name | Type | Description |
---|---|---|
$lastChangeToApply | int |


setLocation(
\Location $location
)
:
void
Sets the location within the buildfile this task occurs. Called by the parser to set location information.
Inherited from: \Task::setLocation()Name | Type | Description |
---|---|---|
$location | \Location | The location object describing the position of this task within the buildfile. |


setOutputFile(
string $outputFile
)
:
void
Set the outputfile which contains all patch sql statements for this deployment
Name | Type | Description |
---|---|---|
$outputFile | string |


setOwningTarget(
\Target $target
)
:
void
Name | Type | Description |
---|---|---|
$target | \Target | Reference to owning target |


setPassword(
string $password
)
:
void
Set the password for the database connection
Name | Type | Description |
---|---|---|
$password | string |


setProject(
\Project $project
)
:
void
References the project to the current component.
Inherited from: \ProjectComponent::setProject()\Task::setProject()Name | Type | Description |
---|---|---|
$project | \Project | The reference to the current project |


setRuntimeConfigurableWrapper(
\RuntimeConfigurable $wrapper
)
:
void
Sets the wrapper object this task should use for runtime configurable elements.
Inherited from: \Task::setRuntimeConfigurableWrapper()Name | Type | Description |
---|---|---|
$wrapper | \RuntimeConfigurable | The wrapper object this task should use |


setTaskName(
string $name
)
:
string
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
string | A string representing the name of this task for log |


setTaskType(
string $name
)
:
void
Sets the type of the task. Usually this is the name of the XML tag
Inherited from: \Task::setTaskType()Name | Type | Description |
---|---|---|
$name | string | The type of this task (XML Tag) |


setUndoOutputFile(
string $undoOutputFile
)
:
void
Set the undo outputfile which contains all undo statements for this deployment
Name | Type | Description |
---|---|---|
$undoOutputFile | string |


setUrl(
string $url
)
:
void
Set the url for the database connection
Name | Type | Description |
---|---|---|
$url | string |


setUserId(
string $userid
)
:
void
Set the userid for the database connection
Name | Type | Description |
---|---|---|
$userid | string |