\Dewdrop\Db\DbdeployChangelogGateway

This class enables other dbdeploy classes to access the dbdeploy changelog database table without having to depend upon direct access to the database. This makes it easier to mock and test the other classes in the dbdeploy module by isolating the database to a single location.

Summary

Methods
Properties
Constants
__construct()
getCurrentRevisionForChangeset()
logAppliedFile()
maintainBackwardCompatibilityOnPrimaryChangeset()
No public properties found
No constants found
tableExists()
createTable()
No protected properties found
N/A
No private methods found
$dbAdapter
$dbType
$cliExec
$tableName
N/A

Properties

$dbAdapter

$dbAdapter : \Dewdrop\Db\Adapter

The database adapter used to read and write to the database.

Type

\Dewdrop\Db\Adapter

$dbType

$dbType : string

The database type we're interacting with. Currently has to be either "pgsql" or "mysql".

Type

string

$cliExec

$cliExec : \Dewdrop\Db\Dbdeploy\CliExec

An object used to run SQL scripts through the psql or mysql CLI tools.

Type

\Dewdrop\Db\Dbdeploy\CliExec

$tableName

$tableName : string

The name of the changelog table in the database. Mostly only changed for testing purposes.

Type

string

Methods

__construct()

__construct(\Dewdrop\Db\Adapter  $dbAdapter, \Dewdrop\Db\Dbdeploy\CliExec  $cliExec, string  $dbType, string  $tableName = 'dbdeploy_changelog') 

The changelog gateway using a DB adapter and a CliExec object to interact with the database. It will use either psql or mysql depending upon the $dbType you supply. For testing, or if you really need a different changelog table name in your application, you can optionally change the table name as well.

Parameters

\Dewdrop\Db\Adapter $dbAdapter
\Dewdrop\Db\Dbdeploy\CliExec $cliExec
string $dbType

Either "pgsql" or "mysql"

string $tableName

getCurrentRevisionForChangeset()

getCurrentRevisionForChangeset(string  $changesetName) : integer

Get the highest revision number applied for the given changeset name.

Parameters

string $changesetName

Returns

integer

logAppliedFile()

logAppliedFile(string  $changesetName, integer  $number, string  $file, string  $appliedBy, string  $startTime, string  $endTime) : integer

Log the execution of a SQL script to the changelog table. The $startTime and $endTime params should be supplied in ISO format (i.e. yyyy-mm-dd hh:mm:ss). The $file param should be the full path to the file, not just the base file name.

Parameters

string $changesetName
integer $number
string $file
string $appliedBy
string $startTime
string $endTime

Returns

integer

maintainBackwardCompatibilityOnPrimaryChangeset()

maintainBackwardCompatibilityOnPrimaryChangeset() 

When Dewdrop was WP-only, the primary dbdeploy changeset was called "plugin".

We now support several environments and calling projects "plugins" doesn't make sense in some cases. To reflect this, the EnvInterface->getProjectNoun() method was added. Because existing projects had "plugin" in the dbdeploy_changelog already, this method is in place to update any of those records on older projects.

tableExists()

tableExists() : boolean

Check to see if the changelog table exists in the database already.

Returns

boolean

createTable()

createTable() : boolean

Create the changelog table in the database. The SQL script used will vary for MySQL and Postgres, though only slightly to account for InnoDB use, etc.

Throws

\Dewdrop\Db\Dbdeploy\Exception

Returns

boolean