This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstallSchema.php
executable file
·144 lines (136 loc) · 4.42 KB
/
InstallSchema.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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();
}
}