Creating an upgrade data script (UpgradeData.php)
The upgrade data script is the last one to execute. We will use it to demonstrate the example of creating the sample entries for our Department
and Employee
entities.
We start by creating the app/code/Foggyline/Office/Setup/UpgradeData.php
file with (partial) content as follows:
namespace Foggyline\Office\Setup; use Magento\Framework\Setup\UpgradeDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class UpgradeData implements UpgradeDataInterface { protected $departmentFactory; protected $employeeFactory; public function __construct( \Foggyline\Office\Model\DepartmentFactory $departmentFactory, \Foggyline\Office\Model\EmployeeFactory $employeeFactory ) { $this->departmentFactory = $departmentFactory; $this->employeeFactory = $employeeFactory; } public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface...