class Migrate

Helper class for migration related console commands.

Constants

MIGRATIONS_PATH

Path to database migration files.

Methods

static bool
batchExists(int $batch)

Test if a particular batch of migrations exists.

static int
dropAllTables()

Drops all tables from the database without using down function.

static string
fileName()

Generates file/class name for migration.

static int
makeMigration(InputInterface $input)

Generates a migration class for creating a new table.

static int
makeRenameMigration(InputInterface $input)

Generates a migration class for renaming an existing table.

static int
makeUpdateMigration(InputInterface $input)

Generates a migration class for updating existing table.

static int
migrate()

Performs migration operation.

static string
migrationClass(string $fileName, string $tableName)

Generates a new Migration class for creating a new table.

static string
migrationRenameClass(string $fileName, string $from, string $to)

Generates a new Migration class for renaming an existing table.

static string
migrationUpdateClass(string $fileName, string $tableName)

Generates a new Migration class for updating a table.

static int
refresh(bool|int $step = false)

Performs refresh operation.

static int
rollback(string|int|bool $batch = false)

Performs roll back operation

static int
rollbackStep(string|int $step)

Perform step roll back.

static int
status()

Reports migration status.

static bool|int
step(string $klassNamespace, bool|int $step = false)

Drops table one at a time.

static int
tableCount()

Determines number of tables in database before performing migration operations.

Details

at line 31
static private bool batchExists(int $batch)

Test if a particular batch of migrations exists.

Parameters

int $batch

The batch value we want to test if it exists.

Return Value

bool

true if exists, otherwise we return false.

at line 45
static int dropAllTables()

Drops all tables from the database without using down function.

Return Value

int

A value that indicates success, invalid, or failure.

at line 78
static string fileName()

Generates file/class name for migration.

Return Value

string

The file/class name of the migration.

at line 88
static int makeMigration(InputInterface $input)

Generates a migration class for creating a new table.

Parameters

InputInterface $input

The Symfony InputInterface object.

Return Value

int

A value that indicates success, invalid, or failure.

at line 106
static int makeRenameMigration(InputInterface $input)

Generates a migration class for renaming an existing table.

Parameters

InputInterface $input

The Symfony InputInterface object.

Return Value

int

A value that indicates success, invalid, or failure.

at line 125
static int makeUpdateMigration(InputInterface $input)

Generates a migration class for updating existing table.

Parameters

InputInterface $input

The Symfony InputInterface object.

Return Value

int

A value that indicates success, invalid, or failure.

at line 142
static int migrate()

Performs migration operation.

Return Value

int

A value that indicates success, invalid, or failure.

at line 214
static string migrationClass(string $fileName, string $tableName)

Generates a new Migration class for creating a new table.

Parameters

string $fileName

The file name for the Migration class.

string $tableName

The name of the table for the migration.

Return Value

string

The contents of the new Migration class.

at line 259
static string migrationRenameClass(string $fileName, string $from, string $to)

Generates a new Migration class for renaming an existing table.

Parameters

string $fileName

The file name for the Migration class.

string $from

The table's original name.

string $to

The new name for the table.

Return Value

string

The contents of the new Migration class.

at line 298
static string migrationUpdateClass(string $fileName, string $tableName)

Generates a new Migration class for updating a table.

Parameters

string $fileName

The file name for the Migration class.

string $tableName

The name of the table for the migration.

Return Value

string

The contents of the new Migration class.

at line 341
static int refresh(bool|int $step = false)

Performs refresh operation.

Parameters

bool|int $step

The number of individual migrations to roll back. When set to false all tables are dropped one by one.

Return Value

int

A value that indicates success, invalid, or failure.

at line 396
static int rollback(string|int|bool $batch = false)

Performs roll back operation

Parameters

string|int|bool $batch

The batch number. If false we assume that we want to roll back latest batch of migrations.

Return Value

int

A value that indicates success, invalid, or failure.

at line 444
static int rollbackStep(string|int $step)

Perform step roll back.

Parameters

string|int $step

Return Value

int

A value that indicates success, invalid, or failure.

at line 457
static int status()

Reports migration status.

Return Value

int

A value that indicates success, invalid, or failure.

at line 513
static private bool|int step(string $klassNamespace, bool|int $step = false)

Drops table one at a time.

Parameters

string $klassNamespace

The name of the migration class.

bool|int $step

The number of individual migrations to roll back. When set to false all tables are dropped one by one.

Return Value

bool|int

$step The number of remaining steps to perform with respect to rolling back migrations. Boolean value of false is returned when no number of steps is provided.

at line 534
static private int tableCount()

Determines number of tables in database before performing migration operations.

Return Value

int

The number of tables in the database.