protected final function Initialize()
{
$MakeAddFunction = function (callable $DefinitionFunction, $Add = false) {
return function (IConnection $Connection, QueryBuilder $QueryBuilder, Table $Table, \Storm\Drivers\Base\Relational\TableTrait $Trait) use(&$DefinitionFunction, &$Add) {
QueryBuilderExtensions::AppendAlterTable($QueryBuilder, $Table);
if ($Add) {
$QueryBuilder->Append('ADD ');
}
$DefinitionFunction($QueryBuilder, $Table, $Trait);
};
};
$this->Register(Mysql\Tables\CharacterSet::GetType(), [$this, 'CharacterSet'], $MakeAddFunction([$this, 'CharacterSet']), [$this, 'DropCharacterSet']);
$this->Register(Mysql\Tables\Collation::GetType(), [$this, 'Collation'], $MakeAddFunction([$this, 'CharacterSet']), [$this, 'DropCollation']);
$this->Register(Traits\Comment::GetType(), [$this, 'Comment'], $MakeAddFunction([$this, 'Comment']), [$this, 'DropComment']);
$this->Register(Mysql\Tables\Engine::GetType(), [$this, 'Engine'], $MakeAddFunction([$this, 'Engine']), [$this, 'DropEngine']);
$this->Register(Traits\ForeignKey::GetType(), [$this, 'ForeignKey'], $MakeAddFunction([$this, 'ForeignKey'], true), [$this, 'DropForeignKey']);
$this->Register(Mysql\Tables\Index::GetType(), [$this, 'Index'], $MakeAddFunction([$this, 'Index'], true), [$this, 'DropIndex']);
$this->Register(Traits\PrimaryKey::GetType(), [$this, 'PrimaryKey'], $MakeAddFunction([$this, 'PrimaryKey'], true), [$this, 'DropPrimaryKey']);
}