Migrator
extends AbstractMigrator
in package
Sql migrator class
Tags
Table of Contents
Properties
- $current : string|null
- Current migration position
- $db : AbstractAdapter|null
- Database adapter
- $migrations : array<string|int, mixed>
- Migrations
- $path : string|null
- Migration path
Methods
- __construct() : mixed
- Constructor
- create() : string
- Create new migration file
- createTable() : Migrator
- Create table
- db() : AbstractAdapter
- Get the DB adapter (alias method)
- getByBatch() : array<string|int, mixed>
- Get migrations by batch
- getCurrent() : string|null
- Get the migration path
- getCurrentBatch() : int
- Get current batch
- getDb() : AbstractAdapter
- Get the DB adapter
- getNextBatch() : int
- Get next batch
- getPath() : string|null
- Get the migration path
- getTable() : string
- Get table class string
- hasTable() : bool
- Determine if the migration source has a table in the DB
- isFile() : bool
- Determine if the migration source is stored in a file
- isTable() : bool
- Determine if the migration source is stored in a DB
- rollback() : Migrator
- Roll back the migrator (down/backward direction)
- rollbackAll() : Migrator
- Roll back all the migrator (down/backward direction)
- run() : Migrator
- Run the migrator (up/forward direction)
- runAll() : Migrator
- Run all the migrator (up/forward direction)
- setPath() : Migrator
- Set the migration path and get migration files
- clearCurrent() : void
- Clear migrations
- deleteCurrent() : void
- Delete migration
- loadCurrent() : void
- Load the current migration timestamp
- storeCurrent() : void
- Store the current migration timestamp
Properties
$current
Current migration position
protected
string|null
$current
= null
$db
Database adapter
protected
AbstractAdapter|null
$db
= null
$migrations
Migrations
protected
array<string|int, mixed>
$migrations
= []
$path
Migration path
protected
string|null
$path
= null
Methods
__construct()
Constructor
public
__construct(AbstractAdapter $db, string $path) : mixed
Instantiate the migrator object
Parameters
- $db : AbstractAdapter
- $path : string
Tags
create()
Create new migration file
public
static create(string $class[, string|null $path = null ]) : string
Parameters
- $class : string
- $path : string|null = null
Tags
Return values
stringcreateTable()
Create table
public
createTable() : Migrator
Return values
Migratordb()
Get the DB adapter (alias method)
public
db() : AbstractAdapter
Return values
AbstractAdaptergetByBatch()
Get migrations by batch
public
getByBatch(string|int $batch) : array<string|int, mixed>
Parameters
- $batch : string|int
Return values
array<string|int, mixed>getCurrent()
Get the migration path
public
getCurrent() : string|null
Return values
string|nullgetCurrentBatch()
Get current batch
public
getCurrentBatch() : int
Return values
intgetDb()
Get the DB adapter
public
getDb() : AbstractAdapter
Return values
AbstractAdaptergetNextBatch()
Get next batch
public
getNextBatch() : int
Return values
intgetPath()
Get the migration path
public
getPath() : string|null
Return values
string|nullgetTable()
Get table class string
public
getTable() : string
Return values
stringhasTable()
Determine if the migration source has a table in the DB
public
hasTable() : bool
Return values
boolisFile()
Determine if the migration source is stored in a file
public
isFile() : bool
Return values
boolisTable()
Determine if the migration source is stored in a DB
public
isTable() : bool
Return values
boolrollback()
Roll back the migrator (down/backward direction)
public
rollback([mixed $steps = 1 ]) : Migrator
Parameters
- $steps : mixed = 1
Return values
MigratorrollbackAll()
Roll back all the migrator (down/backward direction)
public
rollbackAll() : Migrator
Return values
Migratorrun()
Run the migrator (up/forward direction)
public
run([mixed $steps = 1 ]) : Migrator
Parameters
- $steps : mixed = 1
Return values
MigratorrunAll()
Run all the migrator (up/forward direction)
public
runAll() : Migrator
Return values
MigratorsetPath()
Set the migration path and get migration files
public
setPath(string $path) : Migrator
Parameters
- $path : string
Tags
Return values
MigratorclearCurrent()
Clear migrations
protected
clearCurrent() : void
deleteCurrent()
Delete migration
protected
deleteCurrent(int $current[, int|null $previous = null ]) : void
Parameters
- $current : int
- $previous : int|null = null
loadCurrent()
Load the current migration timestamp
protected
loadCurrent() : void
storeCurrent()
Store the current migration timestamp
protected
storeCurrent(int $current, string $classFile[, int|null $batch = null ]) : void
Parameters
- $current : int
- $classFile : string
- $batch : int|null = null