class Illuminate / Database / Migrations / Migrator
You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

Migrator

Properties

protected

$events Dispatcher

The event dispatcher instance.

Default: null
protected

$repository MigrationRepositoryInterface

The migration repository implementation.

Default: null
protected

$files Filesystem

The filesystem instance.

Default: null
protected

$resolver ConnectionResolverInterface

The connection resolver instance.

Default: null
protected

$connection string

The name of the default connection.

Default: null
protected

$paths array

The paths to all of the migration files.

Default: []
protected static

$requiredPathCache array|null>

The paths that have already been required.

Default: []
protected

$output Symfony\...\OutputInterface

The output interface implementation.

Default: null

Methods

public

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

Create a new migrator instance.

Parameters

public

run ( $paths , array $options ) : array

Run the pending migrations at a given path.

Parameters

  • $paths array|string
  • $options array
protected

pendingMigrations ( $files , $ran ) : array

Get the migration files that have not yet run.

Parameters

  • $files array
  • $ran array
public

runPending ( array $migrations , array $options ) : void

Run an array of migrations.

Parameters

  • $migrations array
  • $options array
protected

runUp ( $file , $batch , $pretend ) : void

Run "up" a migration instance.

Parameters

  • $file string
  • $batch int
  • $pretend bool
public

rollback ( $paths , array $options ) : array

Rollback the last migration operation.

Parameters

  • $paths array|string
  • $options array
protected

getMigrationsForRollback ( array $options ) : array

Get the migrations for a rollback operation.

Parameters

  • $options array
protected

rollbackMigrations ( array $migrations , $paths , array $options ) : array

Rollback the given migrations.

Parameters

  • $migrations array
  • $paths array|string
  • $options array
public

reset ( $paths , $pretend ) : array

Rolls all of the currently applied migrations back.

Parameters

  • $paths array|string
  • $pretend bool
protected

resetMigrations ( array $migrations , array $paths , $pretend ) : array

Reset the given migrations.

Parameters

  • $migrations array
  • $paths array
  • $pretend bool
protected

runDown ( $file , $migration , $pretend ) : void

Run "down" a migration instance.

Parameters

  • $file string
  • $migration object
  • $pretend bool
protected

runMigration ( $migration , $method ) : void

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

Parameters

  • $migration object
  • $method string
protected

pretendToRun ( $migration , $method ) : void

Pretend to run the migrations.

Parameters

  • $migration object
  • $method string
protected

getQueries ( $migration , $method ) : array

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

Parameters

  • $migration object
  • $method string
protected

runMethod ( $connection , $migration , $method ) : void

Run a migration method on the given connection.

Parameters

  • $connection Connection
  • $migration object
  • $method string
public

resolve ( $file ) : object

Resolve a migration instance from a file.

Parameters

  • $file string
protected

resolvePath ( string $path ) : object

Resolve a migration instance from a migration path.

Parameters

  • $path string
protected

getMigrationClass ( string $migrationName ) : string

Generate a migration class name based on the migration file name.

Parameters

  • $migrationName string
public

getMigrationFiles ( $paths ) : array

Get all of the migration files in a given path.

Parameters

  • $paths string|array
public

requireFiles ( array $files ) : void

Require in all the migration files in a given path.

Parameters

  • $files array
public

getMigrationName ( $path ) : string

Get the name of the migration.

Parameters

  • $path string
public

path ( $path ) : void

Register a custom migration path.

Parameters

  • $path string
public

paths ( ) : array

Get all of the custom migration paths.

public

getConnection ( ) : string

Get the default connection name.

public

usingConnection ( $name , callable $callback ) : mixed

Execute the given callback using the given connection as the default connection.

Parameters

  • $name string
  • $callback callable
public

setConnection ( $name ) : void

Set the default connection name.

Parameters

  • $name string
public

resolveConnection ( $connection ) : Connection

Resolve the database connection instance.

Parameters

  • $connection string
protected

getSchemaGrammar ( $connection ) : Grammar

Get the schema grammar out of a migration connection.

Parameters

public

getRepository ( ) : MigrationRepositoryInterface

Get the migration repository instance.

public

repositoryExists ( ) : bool

Determine if the migration repository exists.

public

hasRunAnyMigrations ( ) : bool

Determine if any migrations have been run.

public

deleteRepository ( ) : void

Delete the migration repository data store.

public

getFilesystem ( ) : Filesystem

Get the file system instance.

public

setOutput ( Symfony\...\OutputInterface $output ) : $this

Set the output implementation that should be used by the console.

Parameters

  • $output Symfony\...\OutputInterface
protected

write ( $component , $arguments ) : void

Write to the console's output.

Parameters

  • $component string
  • $arguments array|string
public

fireMigrationEvent ( $event ) : void

Fire the given event for the migration.

Parameters