Migrator
in package
Table of Contents
- $connection : string
- The name of the default connection.
- $files : Filesystem
- The filesystem instance.
- $notes : array<string|int, mixed>
- The notes for the current operation.
- $paths : array<string|int, mixed>
- The paths to all of the migration files.
- $repository : MigrationRepositoryInterface
- The migration repository implementation.
- $resolver : ConnectionResolverInterface
- The connection resolver instance.
- __construct() : void
- Create a new migrator instance.
- getFilesystem() : Filesystem
- Get the file system instance.
- getMigrationFiles() : array<string|int, mixed>
- Get all of the migration files in a given path.
- getMigrationName() : string
- Get the name of the migration.
- getNotes() : array<string|int, mixed>
- Get the notes for the last operation.
- getRepository() : MigrationRepositoryInterface
- Get the migration repository instance.
- path() : void
- Register a custom migration path.
- paths() : array<string|int, mixed>
- Get all of the custom migration paths.
- repositoryExists() : bool
- Determine if the migration repository exists.
- requireFiles() : void
- Require in all the migration files in a given path.
- reset() : array<string|int, mixed>
- Rolls all of the currently applied migrations back.
- resolve() : object
- Resolve a migration instance from a file.
- resolveConnection() : Connection
- Resolve the database connection instance.
- rollback() : array<string|int, mixed>
- Rollback the last migration operation.
- run() : array<string|int, mixed>
- Run the pending migrations at a given path.
- runPending() : void
- Run an array of migrations.
- setConnection() : void
- Set the default connection name.
- getMigrationsForRollback() : array<string|int, mixed>
- Get the migrations for a rollback operation.
- getQueries() : array<string|int, mixed>
- Get all of the queries that would be run for a migration.
- getSchemaGrammar() : Grammar
- Get the schema grammar out of a migration connection.
- note() : void
- Raise a note event for the migrator.
- pendingMigrations() : array<string|int, mixed>
- Get the migration files that have not yet run.
- pretendToRun() : void
- Pretend to run the migrations.
- resetMigrations() : array<string|int, mixed>
- Reset the given migrations.
- rollbackMigrations() : array<string|int, mixed>
- Rollback the given migrations.
- runDown() : void
- Run "down" a migration instance.
- runMigration() : void
- Run a migration inside a transaction if the database supports it.
- runUp() : void
- Run "up" a migration instance.
Properties
$connection
The name of the default connection.
protected
string
$connection
$files
The filesystem instance.
protected
Filesystem
$files
$notes
The notes for the current operation.
protected
array<string|int, mixed>
$notes
= []
$paths
The paths to all of the migration files.
protected
array<string|int, mixed>
$paths
= []
$repository
The migration repository implementation.
protected
MigrationRepositoryInterface
$repository
$resolver
The connection resolver instance.
protected
ConnectionResolverInterface
$resolver
Methods
__construct()
Create a new migrator instance.
public
__construct(MigrationRepositoryInterface $repository, ConnectionResolverInterface $resolver, Filesystem $files) : void
Parameters
- $repository : MigrationRepositoryInterface
- $resolver : ConnectionResolverInterface
- $files : Filesystem
Return values
void —getFilesystem()
Get the file system instance.
public
getFilesystem() : Filesystem
Return values
Filesystem —getMigrationFiles()
Get all of the migration files in a given path.
public
getMigrationFiles(string|array<string|int, mixed> $paths) : array<string|int, mixed>
Parameters
- $paths : string|array<string|int, mixed>
Return values
array<string|int, mixed> —getMigrationName()
Get the name of the migration.
public
getMigrationName(string $path) : string
Parameters
- $path : string
Return values
string —getNotes()
Get the notes for the last operation.
public
getNotes() : array<string|int, mixed>
Return values
array<string|int, mixed> —getRepository()
Get the migration repository instance.
public
getRepository() : MigrationRepositoryInterface
Return values
MigrationRepositoryInterface —path()
Register a custom migration path.
public
path(string $path) : void
Parameters
- $path : string
Return values
void —paths()
Get all of the custom migration paths.
public
paths() : array<string|int, mixed>
Return values
array<string|int, mixed> —repositoryExists()
Determine if the migration repository exists.
public
repositoryExists() : bool
Return values
bool —requireFiles()
Require in all the migration files in a given path.
public
requireFiles(array<string|int, mixed> $files) : void
Parameters
- $files : array<string|int, mixed>
Return values
void —reset()
Rolls all of the currently applied migrations back.
public
reset([array<string|int, mixed>|string $paths = [] ][, bool $pretend = false ]) : array<string|int, mixed>
Parameters
- $paths : array<string|int, mixed>|string = []
- $pretend : bool = false
Return values
array<string|int, mixed> —resolve()
Resolve a migration instance from a file.
public
resolve(string $file) : object
Parameters
- $file : string
Return values
object —resolveConnection()
Resolve the database connection instance.
public
resolveConnection(string $connection) : Connection
Parameters
- $connection : string
Return values
Connection —rollback()
Rollback the last migration operation.
public
rollback([array<string|int, mixed>|string $paths = [] ][, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $paths : array<string|int, mixed>|string = []
- $options : array<string|int, mixed> = []
Return values
array<string|int, mixed> —run()
Run the pending migrations at a given path.
public
run([array<string|int, mixed>|string $paths = [] ][, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $paths : array<string|int, mixed>|string = []
- $options : array<string|int, mixed> = []
Return values
array<string|int, mixed> —runPending()
Run an array of migrations.
public
runPending(array<string|int, mixed> $migrations[, array<string|int, mixed> $options = [] ]) : void
Parameters
- $migrations : array<string|int, mixed>
- $options : array<string|int, mixed> = []
Return values
void —setConnection()
Set the default connection name.
public
setConnection(string $name) : void
Parameters
- $name : string
Return values
void —getMigrationsForRollback()
Get the migrations for a rollback operation.
protected
getMigrationsForRollback(array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed>
Return values
array<string|int, mixed> —getQueries()
Get all of the queries that would be run for a migration.
protected
getQueries(object $migration, string $method) : array<string|int, mixed>
Parameters
- $migration : object
- $method : string
Return values
array<string|int, mixed> —getSchemaGrammar()
Get the schema grammar out of a migration connection.
protected
getSchemaGrammar(Connection $connection) : Grammar
Parameters
- $connection : Connection
Return values
Grammar —note()
Raise a note event for the migrator.
protected
note(string $message) : void
Parameters
- $message : string
Return values
void —pendingMigrations()
Get the migration files that have not yet run.
protected
pendingMigrations(array<string|int, mixed> $files, array<string|int, mixed> $ran) : array<string|int, mixed>
Parameters
- $files : array<string|int, mixed>
- $ran : array<string|int, mixed>
Return values
array<string|int, mixed> —pretendToRun()
Pretend to run the migrations.
protected
pretendToRun(object $migration, string $method) : void
Parameters
- $migration : object
- $method : string
Return values
void —resetMigrations()
Reset the given migrations.
protected
resetMigrations(array<string|int, mixed> $migrations, array<string|int, mixed> $paths[, bool $pretend = false ]) : array<string|int, mixed>
Parameters
- $migrations : array<string|int, mixed>
- $paths : array<string|int, mixed>
- $pretend : bool = false
Return values
array<string|int, mixed> —rollbackMigrations()
Rollback the given migrations.
protected
rollbackMigrations(array<string|int, mixed> $migrations, array<string|int, mixed>|string $paths, array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $migrations : array<string|int, mixed>
- $paths : array<string|int, mixed>|string
- $options : array<string|int, mixed>
Return values
array<string|int, mixed> —runDown()
Run "down" a migration instance.
protected
runDown(string $file, object $migration, bool $pretend) : void
Parameters
- $file : string
- $migration : object
- $pretend : bool
Return values
void —runMigration()
Run a migration inside a transaction if the database supports it.
protected
runMigration(object $migration, string $method) : void
Parameters
- $migration : object
- $method : string
Return values
void —runUp()
Run "up" a migration instance.
protected
runUp(string $file, int $batch, bool $pretend) : void
Parameters
- $file : string
- $batch : int
- $pretend : bool