class Migrator

Properties

protected MigrationRepositoryInterface $repository

The migration repository implementation.

protected Filesystem $files

The filesystem instance.

protected ConnectionResolverInterface $resolver

The connection resolver instance.

protected string $connection

The name of the default connection.

protected array $notes

The notes for the current operation.

protected array $paths

The paths to all of the migration files.

Methods

void
__construct(MigrationRepositoryInterface $repository, ConnectionResolverInterface $resolver, Filesystem $files)

Create a new migrator instance.

array
run(array|string $paths = [], array $options = [])

Run the pending migrations at a given path.

array
pendingMigrations(array $files, array $ran)

Get the migration files that have not yet run.

void
runPending(array $migrations, array $options = [])

Run an array of migrations.

void
runUp(string $file, int $batch, bool $pretend)

Run "up" a migration instance.

array
rollback(array|string $paths = [], array $options = [])

Rollback the last migration operation.

array
getMigrationsForRollback(array $options)

Get the migrations for a rollback operation.

array
rollbackMigrations(array $migrations, array|string $paths, array $options)

Rollback the given migrations.

array
reset(array|string $paths = [], bool $pretend = false)

Rolls all of the currently applied migrations back.

array
resetMigrations(array $migrations, array $paths, bool $pretend = false)

Reset the given migrations.

void
runDown(string $file, object $migration, bool $pretend)

Run "down" a migration instance.

void
runMigration(object $migration, string $method)

Run a migration inside a transaction if the database supports it.

void
pretendToRun(object $migration, string $method)

Pretend to run the migrations.

array
getQueries(object $migration, string $method)

Get all of the queries that would be run for a migration.

object
resolve(string $file)

Resolve a migration instance from a file.

array
getMigrationFiles(string|array $paths)

Get all of the migration files in a given path.

void
requireFiles(array $files)

Require in all the migration files in a given path.

string
getMigrationName(string $path)

Get the name of the migration.

void
path(string $path)

Register a custom migration path.

array
paths()

Get all of the custom migration paths.

void
setConnection(string $name)

Set the default connection name.

resolveConnection(string $connection)

Resolve the database connection instance.

getSchemaGrammar(Connection $connection)

Get the schema grammar out of a migration connection.

getRepository()

Get the migration repository instance.

bool
repositoryExists()

Determine if the migration repository exists.

getFilesystem()

Get the file system instance.

void
note(string $message)

Raise a note event for the migrator.

array
getNotes()

Get the notes for the last operation.

Details

at line 63
void __construct(MigrationRepositoryInterface $repository, ConnectionResolverInterface $resolver, Filesystem $files)

Create a new migrator instance.

Parameters

MigrationRepositoryInterface $repository
ConnectionResolverInterface $resolver
Filesystem $files

Return Value

void

at line 79
array run(array|string $paths = [], array $options = [])

Run the pending migrations at a given path.

Parameters

array|string $paths
array $options

Return Value

array

at line 107
protected array pendingMigrations(array $files, array $ran)

Get the migration files that have not yet run.

Parameters

array $files
array $ran

Return Value

array

at line 122
void runPending(array $migrations, array $options = [])

Run an array of migrations.

Parameters

array $migrations
array $options

Return Value

void

at line 162
protected void runUp(string $file, int $batch, bool $pretend)

Run "up" a migration instance.

Parameters

string $file
int $batch
bool $pretend

Return Value

void

at line 194
array rollback(array|string $paths = [], array $options = [])

Rollback the last migration operation.

Parameters

array|string $paths
array $options

Return Value

array

at line 218
protected array getMigrationsForRollback(array $options)

Get the migrations for a rollback operation.

Parameters

array $options

Return Value

array

at line 235
protected array rollbackMigrations(array $migrations, array|string $paths, array $options)

Rollback the given migrations.

Parameters

array $migrations
array|string $paths
array $options

Return Value

array

at line 271
array reset(array|string $paths = [], bool $pretend = false)

Rolls all of the currently applied migrations back.

Parameters

array|string $paths
bool $pretend

Return Value

array

at line 297
protected array resetMigrations(array $migrations, array $paths, bool $pretend = false)

Reset the given migrations.

Parameters

array $migrations
array $paths
bool $pretend

Return Value

array

at line 319
protected void runDown(string $file, object $migration, bool $pretend)

Run "down" a migration instance.

Parameters

string $file
object $migration
bool $pretend

Return Value

void

at line 351
protected void runMigration(object $migration, string $method)

Run a migration inside a transaction if the database supports it.

Parameters

object $migration
string $method

Return Value

void

at line 375
protected void pretendToRun(object $migration, string $method)

Pretend to run the migrations.

Parameters

object $migration
string $method

Return Value

void

at line 391
protected array getQueries(object $migration, string $method)

Get all of the queries that would be run for a migration.

Parameters

object $migration
string $method

Return Value

array

at line 413
object resolve(string $file)

Resolve a migration instance from a file.

Parameters

string $file

Return Value

object

at line 426
array getMigrationFiles(string|array $paths)

Get all of the migration files in a given path.

Parameters

string|array $paths

Return Value

array

at line 443
void requireFiles(array $files)

Require in all the migration files in a given path.

Parameters

array $files

Return Value

void

at line 456
string getMigrationName(string $path)

Get the name of the migration.

Parameters

string $path

Return Value

string

at line 467
void path(string $path)

Register a custom migration path.

Parameters

string $path

Return Value

void

at line 477
array paths()

Get all of the custom migration paths.

Return Value

array

at line 488
void setConnection(string $name)

Set the default connection name.

Parameters

string $name

Return Value

void

at line 505
Connection resolveConnection(string $connection)

Resolve the database connection instance.

Parameters

string $connection

Return Value

Connection

at line 516
protected Grammar getSchemaGrammar(Connection $connection)

Get the schema grammar out of a migration connection.

Parameters

Connection $connection

Return Value

Grammar

at line 532
MigrationRepositoryInterface getRepository()

Get the migration repository instance.

at line 542
bool repositoryExists()

Determine if the migration repository exists.

Return Value

bool

at line 552
Filesystem getFilesystem()

Get the file system instance.

Return Value

Filesystem

at line 563
protected void note(string $message)

Raise a note event for the migrator.

Parameters

string $message

Return Value

void

at line 573
array getNotes()

Get the notes for the last operation.

Return Value

array