public function bake($name)
{
$this->setup();
if (!$this->checkSync()) {
$this->error('Your migrations history is not in sync with your migrations files. ' . 'Make sure all your migrations have been migrated before baking a diff.');
return 1;
}
if (empty($this->migrationsFiles) && empty($this->migratedItems)) {
return $this->bakeSnapshot($name);
}
$collection = $this->getCollection($this->connection);
EventManager::instance()->on('Bake.initialize', function (Event $event) use($collection) {
$event->subject->loadHelper('Migrations.Migration', ['collection' => $collection]);
});
return parent::bake($name);
}