\Dewdrop\Db\DbdeployChangeset

This class simplifies interacting with a dbdeploy changeset.

Given a changeset name, which is used when logging the applied changes in the database, and a filesystem path, where the SQL scripts can be found, this class can tell you:

  1. What revisions have already been applied to the database?
  2. What new revisions are available to apply?
  3. What are the paths to the available SQL files?

Summary

Methods
Properties
Constants
__construct()
getName()
writeNewFile()
getCurrentRevision()
getAvailableRevision()
getAppliedFiles()
getNewFiles()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
findFilesInPath()
getFileChangeNumber()
$changelogGateway
$name
$path
$availableFiles
N/A

Properties

$changelogGateway

$changelogGateway : \Dewdrop\Db\Dbdeploy\ChangelogGateway

The gateway object providing access to the DB's changelog table.

Type

\Dewdrop\Db\Dbdeploy\ChangelogGateway

$name

$name : string

The name of this changeset, as it is stored/tracked in the DB's changelog.

Type

string

$path

$path : string

The path to all the dbdeploy scripts for this changeset in the filesystem.

Type

string

$availableFiles

$availableFiles : array

All the files available in this changeset (applied already or not).

Populated and "cached" when calling findFilesInPath().

Type

array

Methods

__construct()

__construct(\Dewdrop\Db\Dbdeploy\ChangelogGateway  $changelogGateway, string  $name, string  $path) 

Create a changeset object.

Parameters

\Dewdrop\Db\Dbdeploy\ChangelogGateway $changelogGateway
string $name
string $path

getName()

getName() : string

Get the name of this changeset. Useful from the context of Command objects interacting with multiple changesets.

Returns

string

writeNewFile()

writeNewFile(string  $changeName, string  $contents) : string

Write a new change file to the changeset using the next available revision number.

Parameters

string $changeName
string $contents

Returns

string

getCurrentRevision()

getCurrentRevision() : integer

Check the DB changelog to find the highest revision number that has been applied for this changeset.

Returns

integer

getAvailableRevision()

getAvailableRevision() : integer

Check to see the maximum available revision number for this changeset.

Returns

integer

getAppliedFiles()

getAppliedFiles() : array

Get an array of the files that have already been applied to the databse for this changeset. Note that the keys of the array are the revision change numbers.

Returns

array

getNewFiles()

getNewFiles() : array

Get an array of the files that have not yet been applied to the databse for this changeset. Note that the keys of the array are the revision change numbers.

Returns

array

findFilesInPath()

findFilesInPath() : array

Find all valid SQL files in this changeset's path, whether they've been applied already or not. Note that the array keys are the revision change numbers.

Returns

array

getFileChangeNumber()

getFileChangeNumber(string  $file) : integer

Determine the change number for the provided file name. Files should be named in this format:

00001-short-description-of-change.sql

Where "00001" is the change number padded with zeros to 5 digits in order to ensure future changes sort nicely in a file listing and the change number and any words included in the file name are separated by hyphens.

Parameters

string $file

Returns

integer