Skip to content
This repository was archived by the owner on Jun 7, 2022. It is now read-only.

Commit 52d3461

Browse files
committed
Created DB tables
1 parent 88333e9 commit 52d3461

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

Setup/InstallSchema.php

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?php
2+
/**
3+
* Copyright © 2017 Magefan ([email protected]). All rights reserved.
4+
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
*
6+
* Glory to Ukraine! Glory to the heroes!
7+
*/
8+
9+
namespace Magefan\Faq\Setup;
10+
11+
use Magento\Framework\Setup\InstallSchemaInterface;
12+
use Magento\Framework\Setup\ModuleContextInterface;
13+
use Magento\Framework\Setup\SchemaSetupInterface;
14+
use Magento\Framework\DB\Adapter\AdapterInterface;
15+
16+
/**
17+
* Faq setup
18+
*/
19+
class InstallSchema implements InstallSchemaInterface
20+
{
21+
/**
22+
* {@inheritdoc}
23+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
24+
*/
25+
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
26+
{
27+
$installer = $setup;
28+
29+
$installer->startSetup();
30+
31+
/**
32+
* Create table 'magefan_faq'
33+
*/
34+
$table = $installer->getConnection()->newTable(
35+
$installer->getTable('magefan_faq')
36+
)->addColumn(
37+
'faq_id',
38+
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
39+
null,
40+
['identity' => true, 'nullable' => false, 'primary' => true],
41+
'FAQ ID'
42+
)->addColumn(
43+
'title',
44+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
45+
255,
46+
['nullable' => true],
47+
'FAQ Title'
48+
)->addColumn(
49+
'meta_keywords',
50+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
51+
'64k',
52+
['nullable' => true],
53+
'FAQ Meta Keywords'
54+
)->addColumn(
55+
'meta_description',
56+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
57+
'64k',
58+
['nullable' => true],
59+
'FAQ Meta Description'
60+
)->addColumn(
61+
'identifier',
62+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
63+
100,
64+
['nullable' => true, 'default' => null],
65+
'FAQ String Identifier'
66+
)->addColumn(
67+
'content_heading',
68+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
69+
255,
70+
['nullable' => true],
71+
'FAQ Content Heading'
72+
)->addColumn(
73+
'content',
74+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
75+
'2M',
76+
[],
77+
'FAQ Content'
78+
)->addColumn(
79+
'creation_time',
80+
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
81+
null,
82+
[],
83+
'FAQ Creation Time'
84+
)->addColumn(
85+
'update_time',
86+
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
87+
null,
88+
[],
89+
'FAQ Modification Time'
90+
)->addColumn(
91+
'is_active',
92+
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
93+
null,
94+
['nullable' => false, 'default' => '1'],
95+
'Is FAQ Active'
96+
)->addIndex(
97+
$installer->getIdxName('magefan_faq', ['identifier']),
98+
['identifier']
99+
)->setComment(
100+
'Magefan FAQ Table'
101+
);
102+
$installer->getConnection()->createTable($table);
103+
104+
/**
105+
* Create table 'magefan_faq_store'
106+
*/
107+
$table = $installer->getConnection()->newTable(
108+
$installer->getTable('magefan_faq_store')
109+
)->addColumn(
110+
'faq_id',
111+
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
112+
null,
113+
['nullable' => false, 'primary' => true],
114+
'FAQ ID'
115+
)->addColumn(
116+
'store_id',
117+
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
118+
null,
119+
['unsigned' => true, 'nullable' => false, 'primary' => true],
120+
'Store ID'
121+
)->addIndex(
122+
$installer->getIdxName('magefan_faq_store', ['store_id']),
123+
['store_id']
124+
)->addForeignKey(
125+
$installer->getFkName('magefan_faq_store', 'faq_id', 'magefan_faq', 'faq_id'),
126+
'faq_id',
127+
$installer->getTable('magefan_faq'),
128+
'faq_id',
129+
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
130+
)->addForeignKey(
131+
$installer->getFkName('magefan_faq_store', 'store_id', 'store', 'store_id'),
132+
'store_id',
133+
$installer->getTable('store'),
134+
'store_id',
135+
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
136+
)->setComment(
137+
'Magefan FAQ To Store Linkage Table'
138+
);
139+
$installer->getConnection()->createTable($table);
140+
141+
142+
$installer->endSetup();
143+
}
144+
}

0 commit comments

Comments
 (0)