Migrator
class Migrator (View source)
Properties
protected Dispatcher | $events | The event dispatcher instance. |
|
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 | $paths | The paths to all of the migration files. |
|
protected OutputInterface | $output | The output interface implementation. |
Methods
Create a new migrator instance.
Run the pending migrations at a given path.
Get the migration files that have not yet run.
Run an array of migrations.
Run "up" a migration instance.
Rollback the last migration operation.
Get the migrations for a rollback operation.
Rollback the given migrations.
Rolls all of the currently applied migrations back.
Reset the given migrations.
Run "down" a migration instance.
Run a migration inside a transaction if the database supports it.
Pretend to run the migrations.
Get all of the queries that would be run for a migration.
Resolve a migration instance from a file.
Get all of the migration files in a given path.
Require in all the migration files in a given path.
Get the name of the migration.
Register a custom migration path.
Get all of the custom migration paths.
Get the default connection name.
Execute the given callback using the given connection as the default connection.
Set the default connection name.
Resolve the database connection instance.
Get the migration repository instance.
Determine if the migration repository exists.
Get the file system instance.
Set the output implementation that should be used by the console.
Write a note to the console's output.
Details
void
__construct(MigrationRepositoryInterface $repository, ConnectionResolverInterface $resolver, Filesystem $files, Dispatcher $dispatcher = null)
Create a new migrator instance.
array
run(array|string $paths = [], array $options = [])
Run the pending migrations at a given path.
protected 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.
protected 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.
protected array
getMigrationsForRollback(array $options)
Get the migrations for a rollback operation.
protected 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.
protected array
resetMigrations(array $migrations, array $paths, bool $pretend = false)
Reset the given migrations.
protected void
runDown(string $file, object $migration, bool $pretend)
Run "down" a migration instance.
protected void
runMigration(object $migration, string $method)
Run a migration inside a transaction if the database supports it.
protected void
pretendToRun(object $migration, string $method)
Pretend to run the migrations.
protected 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.
string
getConnection()
Get the default connection name.
mixed
usingConnection(string $name, callable $callback)
Execute the given callback using the given connection as the default connection.
void
setConnection(string $name)
Set the default connection name.
Connection
resolveConnection(string $connection)
Resolve the database connection instance.
protected Grammar
getSchemaGrammar(Connection $connection)
Get the schema grammar out of a migration connection.
MigrationRepositoryInterface
getRepository()
Get the migration repository instance.
bool
repositoryExists()
Determine if the migration repository exists.
Filesystem
getFilesystem()
Get the file system instance.
$this
setOutput(OutputInterface $output)
Set the output implementation that should be used by the console.
protected void
note(string $message)
Write a note to the console's output.
void
fireMigrationEvent(MigrationEvent $event)
Fire the given event for the migration.