private function addColumns(Schema
$schema, Table
$table, array
$fields): void
{ $name =
$table->
getName();
$binary =
['length' => 16, 'fixed' => true
];
$onDelete =
[ 'set-null' =>
['onUpdate' => 'cascade', 'onDelete' => 'set null'
],
'cascade' =>
['onUpdate' => 'cascade', 'onDelete' => 'cascade'
],
'restrict' =>
['onUpdate' => 'cascade', 'onDelete' => 'restrict'
],
];
if (!
$table->
hasColumn('created_at'
)) { $table->
addColumn('created_at', Types::DATETIME_MUTABLE,
['notnull' => true
]);
} if (!
$table->
hasColumn('updated_at'
)) { $table->
addColumn('updated_at', Types::DATETIME_MUTABLE,
['notnull' => false
]);
} foreach ($fields as $field) { $required =
$field['required'
] ?? false;
$nullable =
$required ?
[] :
['notnull' => false, 'default' => null
];