protected function getColumns()
{
foreach ($this->commonTables as $table => $currentSchema) {
$currentColumns = $currentSchema->columns();
$oldColumns = $this->dumpSchema[$table]->columns();
// brand new columns
$addedColumns = array_diff($currentColumns, $oldColumns);
foreach ($addedColumns as $columnName) {
$this->templateData[$table]['columns']['add'][$columnName] = $currentSchema->column($columnName);
}
// changes in columns meta-data
foreach ($currentColumns as $columnName) {
$column = $currentSchema->column($columnName);
unset($column['collate']);
$oldColumn = $this->dumpSchema[$table]->column($columnName);
if (in_array($columnName, $oldColumns) && $column !== $oldColumn) {
$changedAttributes = array_diff($column, $oldColumn);
if (!isset($changedAttributes['type'])) {
$changedAttributes['type'] = $column['type'];
}
$this->templateData[$table]['columns']['changed'][$columnName] = $changedAttributes;
}
}
// columns deletion
if (!isset($this->templateData[$table]['columns']['remove'])) {
$this->templateData[$table]['columns']['remove'] = [];
}
$removedColumns = array_diff($oldColumns, $currentColumns);
if (!empty($removedColumns)) {
foreach ($removedColumns as $column) {
$this->templateData[$table]['columns']['remove'][$column] = $this->dumpSchema[$table]->column($column);
}
}
}
}