|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Firegento\DevDashboard\Setup; |
|
4
|
|
|
|
|
5
|
|
|
use Magento\Framework\DB\Adapter\AdapterInterface; |
|
6
|
|
|
use Magento\Framework\DB\Ddl\Table; |
|
7
|
|
|
|
|
8
|
|
|
class UpgradeSchema implements \Magento\Framework\Setup\UpgradeSchemaInterface |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @param \Magento\Framework\Setup\SchemaSetupInterface $setup |
|
12
|
|
|
* @param \Magento\Framework\Setup\ModuleContextInterface $context |
|
13
|
|
|
* @throws \Zend_Db_Exception |
|
14
|
|
|
*/ |
|
15
|
|
|
public function upgrade(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context) |
|
16
|
|
|
{ |
|
17
|
|
|
$installer = $setup; |
|
18
|
|
|
$installer->startSetup(); |
|
19
|
|
|
|
|
20
|
|
|
if (version_compare($context->getVersion(), '1.0.1', '<')) { |
|
21
|
|
|
|
|
22
|
|
|
$table = $installer->getConnection()->newTable( |
|
23
|
|
|
$installer->getTable('firegento_devdashboard_config') |
|
24
|
|
|
)->addColumn( |
|
25
|
|
|
'firegento_devdashboard_config_id', |
|
26
|
|
|
Table::TYPE_INTEGER, |
|
27
|
|
|
null, |
|
28
|
|
|
['identity' => true, 'nullable' => false, 'primary' => true, 'unsigned' => true,], |
|
29
|
|
|
'Entity ID' |
|
30
|
|
|
)->addColumn( |
|
31
|
|
|
'user_id', |
|
32
|
|
|
Table::TYPE_INTEGER, |
|
33
|
|
|
null, |
|
34
|
|
|
['unsigned' => true, 'nullable' => false], |
|
35
|
|
|
'Admin User Id' |
|
36
|
|
|
)->addColumn( |
|
37
|
|
|
'creation_time', |
|
38
|
|
|
Table::TYPE_TIMESTAMP, |
|
39
|
|
|
null, |
|
40
|
|
|
['nullable' => false, 'default' => Table::TIMESTAMP_INIT,], |
|
41
|
|
|
'Creation Time' |
|
42
|
|
|
)->addColumn( |
|
43
|
|
|
'update_time', |
|
44
|
|
|
Table::TYPE_TIMESTAMP, |
|
45
|
|
|
null, |
|
46
|
|
|
['nullable' => false, 'default' => Table::TIMESTAMP_INIT_UPDATE,], |
|
47
|
|
|
'Modification Time' |
|
48
|
|
|
)->addColumn( |
|
49
|
|
|
'configuration', |
|
50
|
|
|
Table::TYPE_TEXT, |
|
51
|
|
|
null, |
|
52
|
|
|
[], |
|
53
|
|
|
'Configuration' |
|
54
|
|
|
)->addColumn( |
|
55
|
|
|
'use_devdashboard', |
|
56
|
|
|
Table::TYPE_SMALLINT, |
|
57
|
|
|
null, |
|
58
|
|
|
['nullable' => false, 'default' => '0',], |
|
59
|
|
|
'Use Developer Dashboard' |
|
60
|
|
|
)->addColumn( |
|
61
|
|
|
'is_active', |
|
62
|
|
|
Table::TYPE_SMALLINT, |
|
63
|
|
|
null, |
|
64
|
|
|
['nullable' => false, 'default' => '1',], |
|
65
|
|
|
'Use Developer Dashboard' |
|
66
|
|
|
)->addForeignKey( |
|
67
|
|
|
$installer->getFkName( |
|
68
|
|
|
'firegento_devdashboard_config', |
|
69
|
|
|
'user_id', |
|
70
|
|
|
'admin_user', |
|
71
|
|
|
'user_id' |
|
72
|
|
|
), |
|
73
|
|
|
'user_id', |
|
74
|
|
|
$installer->getTable('admin_user'), |
|
75
|
|
|
'user_id', |
|
76
|
|
|
Table::ACTION_CASCADE |
|
77
|
|
|
)->addIndex( |
|
78
|
|
|
$installer->getIdxName( |
|
79
|
|
|
'firegento_devdashboard_config', |
|
80
|
|
|
['user_id'], |
|
81
|
|
|
AdapterInterface::INDEX_TYPE_INDEX), |
|
82
|
|
|
['user_id'] |
|
83
|
|
|
|
|
84
|
|
|
); |
|
85
|
|
|
$installer->getConnection()->createTable($table); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$installer->endSetup(); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|