Migrator

class Migrator (View source)

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 outstanding migrations at a given path.

void runMigrationList(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 reset(array|string $paths = [], bool $pretend = false)

Rolls all of the currently applied migrations back.

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

Run "down" a migration instance.

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.

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.

void runMigration(object $migration, string $method)

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

Grammar getSchemaGrammar(Connection $connection)

Get the schema grammar out of a migration connection.

object resolve(string $file)

Resolve a migration instance from a file.

string getMigrationName(string $path)

Get the name of the migration.

void note(string $message)

Raise a note event for the migrator.

array getNotes()

Get the notes for the last operation.

Connection resolveConnection(string $connection)

Resolve the database connection instance.

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.

MigrationRepositoryInterface getRepository()

Get the migration repository instance.

bool repositoryExists()

Determine if the migration repository exists.

Filesystem getFilesystem()

Get the file system instance.

Details

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

Create a new migrator instance.

Parameters

MigrationRepositoryInterface $repository
ConnectionResolverInterface $resolver
Filesystem $files

Return Value

void

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

Run the outstanding migrations at a given path.

Parameters

array|string $paths
array $options

Return Value

array

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

Run an array of migrations.

Parameters

array $migrations
array $options

Return Value

void

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

Run "up" a migration instance.

Parameters

string $file
int $batch
bool $pretend

Return Value

void

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

Rollback the last migration operation.

Parameters

array|string $paths
array $options

Return Value

array

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

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

Run "down" a migration instance.

Parameters

string $file
object $migration
bool $pretend

Return Value

void

array getMigrationFiles(string|array $paths)

Get all of the migration files in a given path.

Parameters

string|array $paths

Return Value

array

void requireFiles(array $files)

Require in all the migration files in a given path.

Parameters

array $files

Return Value

void

protected void pretendToRun(object $migration, string $method)

Pretend to run the migrations.

Parameters

object $migration
string $method

Return Value

void

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

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

protected Grammar getSchemaGrammar(Connection $connection)

Get the schema grammar out of a migration connection.

Parameters

Connection $connection

Return Value

Grammar

object resolve(string $file)

Resolve a migration instance from a file.

Parameters

string $file

Return Value

object

string getMigrationName(string $path)

Get the name of the migration.

Parameters

string $path

Return Value

string

protected void note(string $message)

Raise a note event for the migrator.

Parameters

string $message

Return Value

void

array getNotes()

Get the notes for the last operation.

Return Value

array

Connection resolveConnection(string $connection)

Resolve the database connection instance.

Parameters

string $connection

Return Value

Connection

void path(string $path)

Register a custom migration path.

These path will not automatically be applied.

Parameters

string $path

Return Value

void

array paths()

Get all of the custom migration paths.

Return Value

array

void setConnection(string $name)

Set the default connection name.

Parameters

string $name

Return Value

void

MigrationRepositoryInterface getRepository()

Get the migration repository instance.

bool repositoryExists()

Determine if the migration repository exists.

Return Value

bool

Filesystem getFilesystem()

Get the file system instance.

Return Value

Filesystem

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.3/Illuminate/Database/Migrations/Migrator.html