Creating an installation script (InstallSchema.php)
InstallSchema
, or install script, is a way for us to set up tables in the database that will be used to persist our models later on.
If we look back at the module requirements, the following fields need to be created in the foggyline_helpdesk_ticket
table:
ticket_id
customer_id
title
severity
created_at
status
Our InstallSchema
is defined under the app/code/Foggyline/Helpdesk/Setup/InstallSchema.php
file with (partial) content as follows:
<?php namespace Foggyline\Helpdesk\Setup; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; /** * @codeCoverageIgnore */ class InstallSchema implements InstallSchemaInterface { public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) { $installer = $setup; $installer->startSetup(); $table = $installer->getConnection() -...