Skip to content
Permalink
Browse files

Created DB tables

  • Loading branch information...
ihorvansach committed Sep 12, 2017
1 parent 88333e9 commit 52d34616bcde6efd40e0e967a95814217b0514ca
Showing with 144 additions and 0 deletions.
  1. +144 −0 Setup/InstallSchema.php
@@ -0,0 +1,144 @@
<?php
/**
* Copyright © 2017 Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
*
* Glory to Ukraine! Glory to the heroes!
*/
namespace Magefan\Faq\Setup;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;
/**
* Faq setup
*/
class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
/**
* Create table 'magefan_faq'
*/
$table = $installer->getConnection()->newTable(
$installer->getTable('magefan_faq')
)->addColumn(
'faq_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'nullable' => false, 'primary' => true],
'FAQ ID'
)->addColumn(
'title',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['nullable' => true],
'FAQ Title'
)->addColumn(
'meta_keywords',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'64k',
['nullable' => true],
'FAQ Meta Keywords'
)->addColumn(
'meta_description',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'64k',
['nullable' => true],
'FAQ Meta Description'
)->addColumn(
'identifier',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
100,
['nullable' => true, 'default' => null],
'FAQ String Identifier'
)->addColumn(
'content_heading',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['nullable' => true],
'FAQ Content Heading'
)->addColumn(
'content',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'2M',
[],
'FAQ Content'
)->addColumn(
'creation_time',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
[],
'FAQ Creation Time'
)->addColumn(
'update_time',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
[],
'FAQ Modification Time'
)->addColumn(
'is_active',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '1'],
'Is FAQ Active'
)->addIndex(
$installer->getIdxName('magefan_faq', ['identifier']),
['identifier']
)->setComment(
'Magefan FAQ Table'
);
$installer->getConnection()->createTable($table);
/**
* Create table 'magefan_faq_store'
*/
$table = $installer->getConnection()->newTable(
$installer->getTable('magefan_faq_store')
)->addColumn(
'faq_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['nullable' => false, 'primary' => true],
'FAQ ID'
)->addColumn(
'store_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'primary' => true],
'Store ID'
)->addIndex(
$installer->getIdxName('magefan_faq_store', ['store_id']),
['store_id']
)->addForeignKey(
$installer->getFkName('magefan_faq_store', 'faq_id', 'magefan_faq', 'faq_id'),
'faq_id',
$installer->getTable('magefan_faq'),
'faq_id',
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('magefan_faq_store', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Magefan FAQ To Store Linkage Table'
);
$installer->getConnection()->createTable($table);
$installer->endSetup();
}
}

0 comments on commit 52d3461

Please sign in to comment.
You can’t perform that action at this time.