-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathUpgradeSchema.php
More file actions
43 lines (36 loc) · 1.54 KB
/
UpgradeSchema.php
File metadata and controls
43 lines (36 loc) · 1.54 KB
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
<?php
namespace PCAPredict\Tag\Setup;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\UpgradeSchemaInterface;
// Upgrade will only trigger if the setup_version in the module.xml is increased.
class UpgradeSchema implements UpgradeSchemaInterface
{
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '2.0.7', '<')) {
// Get module table
$tableName = $setup->getTable('pcapredict_tag_settingsdata');
// Check if the table already exists
if ($setup->getConnection()->isTableExists($tableName) === true) {
// Remove any columns we don't need.
$setup->getConnection()->dropColumn($tableName, 'update_time');
// Add the version column so we can record what version of the app the creds were created from.
// In UpgradeData we set this column to the current version.
$setup->getConnection()->addColumn(
$tableName,
'module_version',
[
'type' => Table::TYPE_TEXT,
'length' => 16,
'nullable' => true,
'comment' => 'Created With App Version',
]
);
}
}
$setup->endSetup();
}
}