com\setasign\SetaFramework\Database\Migration

MigrationManager Class MigrationManager

File: /SetaFramework/src/Database/Migration/MigrationManager.php

Note: The migration manager is not transaction safe! Make sure that never multiple migration managers run at the same time and no other script changes the migrations table.

Class hierarchy

Implements

Summary

Constants

TABLE_NAME

public const MigrationManager::TABLE_NAME = 'migrations'

Properties

$directory

protected string MigrationManager::$directory

$migrations

$name

protected string MigrationManager::$name

Static Methods


Methods

__construct()

Parameters
$database : \com\setasign\SetaFramework\Database\Database
 
$migrationTable : \com\setasign\SetaFramework\Database\TableInterface
 
$directory : string
 
$name : string
 

generateNewMigration()

getMissingMigrations()

public MigrationManager::getMissingMigrations (
void
): array

hasMigration()

public MigrationManager::hasMigration (
string $name
): bool
Parameters
$name : string
 

loadMigrationClass()

private MigrationManager::loadMigrationClass (
string $name,
string $file
): MigrationInterface
Parameters
$name : string
 
$file : string
 

lookForMigrations()

private MigrationManager::lookForMigrations (
void
): void

revertSingleMigration()

public MigrationManager::revertSingleMigration (
string $name
): void
Parameters
$name : string
 
Exceptions

Throws MigrationDownException

revertUntil()

Parameters
$dateTime : \DateTimeInterface
 
Return Values

Number of migrations which were installed

Exceptions

Throws MigrationDownException If an error happens while running down()

run()

public MigrationManager::run (
void
): int
Return Values

Number of migrations which were installed

Exceptions

Throws MigrationUpException If an error happens while running up()

Throws MigrationDownException If an error happens while running down()

Throws \com\setasign\SetaFramework\Exception If the migration row cannot be saved

runMigrationFailSafe()

private MigrationManager::runMigrationFailSafe (
string $name,
MigrationInterface $migration
): void
Parameters
$name : string
 
$migration : MigrationInterface
 
Exceptions

Throws MigrationUpException If an error happens while running up()

Throws MigrationDownException If an error happens while running down()

Throws \com\setasign\SetaFramework\Exception If the migration row cannot be saved

runSingleMigration()

public MigrationManager::runSingleMigration (
string $name
): void
Parameters
$name : string
 
Exceptions

Throws MigrationUpException If an error happens while running up()

Throws MigrationDownException If an error happens while running down()

Throws \com\setasign\SetaFramework\Exception If the migration row cannot be saved

Throws \InvalidArgumentException If the migration is unknown or already installed