Index Documentation

DbMigrationManager
in package

Provides a common interface for database migrations.

Table of Contents

Constants

DEFAULT_TABLE  = 'ndx_migrations'
Default table name for migrations.

Methods

__construct()  : mixed
checkMigration()  : bool
Checks if a particular migration is present in the tracking table.
completeMigration()  : void
Marks a migration as completed in the tracking table.
createClassName()  : string
Generates a class name for a migration PHP file.
createFileName()  : string
Generates a filename for a migration PHP file.
createNames()  : object
Generate names for a PHP migration file.
createTrackingTable()  : void
Creates the migration tracking table if it doesn't exist.
destroyTrackingTable()  : void
Deletes the migration tracking table.
init()  : void
Runs all preparations required for running migrations.
prepareStatements()  : void
Prepares statements required for migrations.
processMigrations()  : array<string|int, string>
Runs all migrations present in a migration repository. This process is irreversible!
template()  : string
Generates a template for a migration PHP file.

Constants

DEFAULT_TABLE

Default table name for migrations.

public string DEFAULT_TABLE = 'ndx_migrations'

Methods

__construct()

public __construct(IDbConnection $conn[, string $tableName = self::DEFAULT_TABLE ]) : mixed
Parameters
$conn : IDbConnection

Connection to apply to migrations to.

$tableName : string = self::DEFAULT_TABLE

Name of the migration tracking table.

checkMigration()

Checks if a particular migration is present in the tracking table.

public checkMigration(string $name) : bool
Parameters
$name : string

Name of the migration.

Tags
throws
RuntimeException

If the migration manager has not been initialised.

Return values
bool

true if the migration has been run, false otherwise.

completeMigration()

Marks a migration as completed in the tracking table.

public completeMigration(string $name[, DateTimeInterface|null $dateTime = null ]) : void
Parameters
$name : string

Name of the migration.

$dateTime : DateTimeInterface|null = null

Timestamp of when the migration was run, null for now.

Tags
throws
RuntimeException

If the migration manager has not been initialised.

createClassName()

Generates a class name for a migration PHP file.

public createClassName(string $name[, DateTimeInterface|null $dateTime = null ]) : string
Parameters
$name : string

Name of the migration.

$dateTime : DateTimeInterface|null = null

Timestamp of when the migration was created, null for now.

Tags
throws
InvalidArgumentException

If $name is empty.

throws
InvalidArgumentException

If $name contains invalid characters.

Return values
string

Migration class name.

createFileName()

Generates a filename for a migration PHP file.

public createFileName(string $name[, DateTimeInterface|null $dateTime = null ]) : string
Parameters
$name : string

Name of the migration.

$dateTime : DateTimeInterface|null = null

Timestamp of when the migration was created, null for now.

Tags
throws
InvalidArgumentException

If $name is empty.

throws
InvalidArgumentException

If $name contains invalid characters.

Return values
string

Migration filename.

createNames()

Generate names for a PHP migration file.

public createNames(string $baseName[, DateTimeInterface|null $dateTime = null ]) : object
Parameters
$baseName : string

Name of the migration.

$dateTime : DateTimeInterface|null = null

Timestamp of when the migration was created, null for now.

Return values
object

Object containing names for a PHP migration file.

createTrackingTable()

Creates the migration tracking table if it doesn't exist.

public createTrackingTable() : void

destroyTrackingTable()

Deletes the migration tracking table.

public destroyTrackingTable() : void

init()

Runs all preparations required for running migrations.

public init() : void

prepareStatements()

Prepares statements required for migrations.

public prepareStatements() : void

processMigrations()

Runs all migrations present in a migration repository. This process is irreversible!

public processMigrations(IDbMigrationRepo $migrations) : array<string|int, string>
Parameters
$migrations : IDbMigrationRepo

Migrations repository to fetch migrations from.

Return values
array<string|int, string>

Names of migrations that have been completed.

template()

Generates a template for a migration PHP file.

public template(string $name) : string
Parameters
$name : string

Name of the migration.

Return values
string

Migration template.


        
On this page

Search results