| Current Path : /var/www/html/app/code/FlipsDigital/CustomerTextbookList/Setup/ |
| Current File : /var/www/html/app/code/FlipsDigital/CustomerTextbookList/Setup/InstallSchema.php |
<?php
/**
* installSchema.php
*
* @copyright Copyright © 2021 FlipsDigital. All rights reserved.
* @author calvin.so@flipsdigital.com
*/
namespace FlipsDigital\CustomerTextbookList\Setup;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use FlipsDigital\CustomerTextbookList\Setup\EavTablesSetupFactory;
/**
* @codeCoverageIgnore
*/
class InstallSchema implements InstallSchemaInterface
{
/**
* @var EavTablesSetupFactory
*/
protected $eavTablesSetupFactory;
/**
* Init
*
* @internal param EavTablesSetupFactory $EavTablesSetupFactory
*/
public function __construct(EavTablesSetupFactory $eavTablesSetupFactory)
{
$this->eavTablesSetupFactory = $eavTablesSetupFactory;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) //@codingStandardsIgnoreLine
{
$setup->startSetup();
$tableName = CustomerTextbookListSetup::ENTITY_TYPE_CODE . '_entity';
/**
* Create entity Table
*/
$table = $setup->getConnection()
->newTable($setup->getTable($tableName))
->addColumn(
'entity_id',
Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Entity ID'
)->setComment('Entity Table');
$table->addColumn(
'identifier',
Table::TYPE_TEXT,
100,
['nullable' => false],
'Identifier'
)->addIndex(
$setup->getIdxName($tableName, ['identifier']),
['identifier']
);
// Add more static attributes here...
$table->addColumn(
'created_at',
Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => Table::TIMESTAMP_INIT],
'Creation Time'
)->addColumn(
'updated_at',
Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => Table::TIMESTAMP_INIT_UPDATE],
'Update Time'
);
$setup->getConnection()->createTable($table);
/** @var \FlipsDigital\CustomerTextbookList\Setup\EavTablesSetup $eavTablesSetup */
$eavTablesSetup = $this->eavTablesSetupFactory->create(['setup' => $setup]);
$eavTablesSetup->createEavTables(CustomerTextbookListSetup::ENTITY_TYPE_CODE);
$setup->endSetup();
}
}