PHP Class Migrations\Shell\Task\MigrationDiffTask

Inheritance: extends Migrations\Shell\Task\SimpleMigrationTask, use trait Migrations\Shell\Task\SnapshotTrait, use trait Migrations\Util\UtilTrait
Datei anzeigen Open project: cakephp/migrations

Protected Properties

Property Type Description
$commonTables array List of the tables that are commonly found in the dump schema and the current schema
$currentSchema array Array of \Cake\Database\Schema\Table objects from the current state of the database
$dumpSchema array Array of \Cake\Database\Schema\Table objects from the dump file which represents the state of the database after the last migrate / rollback command
$migratedItems array Array of migrations that have already been migrated
$migrationsFiles array Migration files that are stored in the self::migrationsPath
$migrationsPath string Path to the migration files
$phinxTable string Name of the phinx log table
$tables array List the tables the connection currently holds
$templateData {@inheritDoc}

Public Methods

Method Description
bake ( $name ) {@inheritDoc}
getCollection ( string $connection ) : Cake\Database\Schema\Collection Get a collection from a database.
getOptionParser ( ) : Cake\Console\ConsoleOptionParser Gets the option parser instance and configures it.
setup ( ) : void Sets up everything the baking process needs
template ( ) {@inheritDoc}
templateData ( ) : array Process and prepare the data needed for the bake template to be generated.

Protected Methods

Method Description
bakeSnapshot ( $name ) : integer Fallback method called to bake a snapshot when the phinx log history is empty and there are no migration files.
calculateDiff ( ) : void This methods runs the various methods needed to calculate a diff between the current state of the database and the schema dump file.
checkSync ( ) : boolean Checks that the migrations history is in sync with the migrations files
getColumns ( ) : void Calculate the diff between columns in existing tables.
getConstraints ( ) : void Calculate the diff between contraints in existing tables.
getCurrentSchema ( ) : array Reflects the current database schema.
getDumpSchema ( ) : array Fetch the correct schema dump based on the arguments and options passed to the shell call and returns it as an array
getIndexes ( ) : void Calculate the diff between indexes in existing tables.
getTables ( ) : void Calculate the diff between the current state of the database and the schema dump by returning an array containing the full \Cake\Database\Schema\Table definitions of tables to be created and removed in the diff file.

Method Details

bake() public method

{@inheritDoc}
public bake ( $name )

bakeSnapshot() protected method

Fallback method called to bake a snapshot when the phinx log history is empty and there are no migration files.
protected bakeSnapshot ( $name ) : integer
return integer Value of the snapshot baking dispatch process

calculateDiff() protected method

This methods runs the various methods needed to calculate a diff between the current state of the database and the schema dump file.
protected calculateDiff ( ) : void
return void

checkSync() protected method

Checks that the migrations history is in sync with the migrations files
protected checkSync ( ) : boolean
return boolean Whether migrations history is sync or not

getCollection() public method

Get a collection from a database.
public getCollection ( string $connection ) : Cake\Database\Schema\Collection
$connection string Database connection name.
return Cake\Database\Schema\Collection

getColumns() protected method

This will look for columns addition, columns removal and changes in columns metadata such as change of types or property such as length. Note that the method is not able to detect columns name change. The method directly sets the diff in a property of the class.
protected getColumns ( ) : void
return void

getConstraints() protected method

This will look for contraints addition, contraints removal and changes in contraints metadata such as change of referenced columns if the old constraints and the new one have the same name. The method directly sets the diff in a property of the class.
protected getConstraints ( ) : void
return void

getCurrentSchema() protected method

Reflects the current database schema.
protected getCurrentSchema ( ) : array
return array Full database schema : the key is the name of the table and the value is an instance of \Cake\Database\Schema\Table.

getDumpSchema() protected method

Fetch the correct schema dump based on the arguments and options passed to the shell call and returns it as an array
protected getDumpSchema ( ) : array
return array Full database schema : the key is the name of the table and the value is an instance of \Cake\Database\Schema\Table.

getIndexes() protected method

This will look for indexes addition, indexes removal and changes in indexes metadata such as change of referenced columns if the old indexes and the new one have the same name. The method directly sets the diff in a property of the class.
protected getIndexes ( ) : void
return void

getOptionParser() public method

Gets the option parser instance and configures it.
public getOptionParser ( ) : Cake\Console\ConsoleOptionParser
return Cake\Console\ConsoleOptionParser

getTables() protected method

The method directly sets the diff in a property of the class.
protected getTables ( ) : void
return void

setup() public method

Sets up everything the baking process needs
public setup ( ) : void
return void

template() public method

{@inheritDoc}
public template ( )

templateData() public method

Process and prepare the data needed for the bake template to be generated.
public templateData ( ) : array
return array

Property Details

$commonTables protected_oe property

List of the tables that are commonly found in the dump schema and the current schema
protected array $commonTables
return array

$currentSchema protected_oe property

Array of \Cake\Database\Schema\Table objects from the current state of the database
protected array $currentSchema
return array

$dumpSchema protected_oe property

Array of \Cake\Database\Schema\Table objects from the dump file which represents the state of the database after the last migrate / rollback command
protected array $dumpSchema
return array

$migratedItems protected_oe property

Array of migrations that have already been migrated
protected array $migratedItems
return array

$migrationsFiles protected_oe property

Migration files that are stored in the self::migrationsPath
protected array $migrationsFiles
return array

$migrationsPath protected_oe property

Path to the migration files
protected string $migrationsPath
return string

$phinxTable protected_oe property

Name of the phinx log table
protected string $phinxTable
return string

$tables protected_oe property

List the tables the connection currently holds
protected array $tables
return array

$templateData protected_oe property

{@inheritDoc}
protected $templateData