@@ -33,11 +33,8 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
33
33
$ this ->addUniqueKeyToCategoryProductTable ($ setup );
34
34
}
35
35
36
- if (version_compare ($ context ->getVersion (), '2.1.0 ' , '< ' )) {
36
+ if (version_compare ($ context ->getVersion (), '2.1.4 ' , '< ' )) {
37
37
$ this ->addPercentageValueColumn ($ setup );
38
- }
39
-
40
- if (version_compare ($ context ->getVersion (), '2.1.1 ' , '< ' )) {
41
38
$ tables = [
42
39
'catalog_product_index_price_cfg_opt_agr_idx ' ,
43
40
'catalog_product_index_price_cfg_opt_agr_tmp ' ,
@@ -59,13 +56,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
59
56
['type ' => 'integer ' , 'nullable ' => false ]
60
57
);
61
58
}
62
- }
63
-
64
- if (version_compare ($ context ->getVersion (), '2.1.2 ' , '< ' )) {
65
59
$ this ->addSourceEntityIdToProductEavIndex ($ setup );
66
- }
67
-
68
- if (version_compare ($ context ->getVersion (), '2.1.4 ' , '< ' )) {
69
60
$ this ->recreateCatalogCategoryProductIndexTmpTable ($ setup );
70
61
}
71
62
@@ -93,25 +84,27 @@ private function addSourceEntityIdToProductEavIndex(SchemaSetupInterface $setup)
93
84
$ connection = $ setup ->getConnection ();
94
85
foreach ($ tables as $ tableName ) {
95
86
$ tableName = $ setup ->getTable ($ tableName );
96
- $ connection ->addColumn (
97
- $ tableName ,
98
- 'source_id ' ,
99
- [
100
- 'type ' => \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
101
- 'unsigned ' => true ,
102
- 'nullable ' => false ,
103
- 'default ' => 0 ,
104
- 'comment ' => 'Original entity Id for attribute value ' ,
105
- ]
106
- );
107
- $ connection ->dropIndex ($ tableName , $ connection ->getPrimaryKeyName ($ tableName ));
108
- $ primaryKeyFields = ['entity_id ' , 'attribute_id ' , 'store_id ' , 'value ' , 'source_id ' ];
109
- $ setup ->getConnection ()->addIndex (
110
- $ tableName ,
111
- $ connection ->getIndexName ($ tableName , $ primaryKeyFields ),
112
- $ primaryKeyFields ,
113
- \Magento \Framework \DB \Adapter \AdapterInterface::INDEX_TYPE_PRIMARY
114
- );
87
+ if (!$ connection ->tableColumnExists ($ tableName , 'source_id ' )) {
88
+ $ connection ->addColumn (
89
+ $ tableName ,
90
+ 'source_id ' ,
91
+ [
92
+ 'type ' => \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER ,
93
+ 'unsigned ' => true ,
94
+ 'nullable ' => false ,
95
+ 'default ' => 0 ,
96
+ 'comment ' => 'Original entity Id for attribute value ' ,
97
+ ]
98
+ );
99
+ $ connection ->dropIndex ($ tableName , $ connection ->getPrimaryKeyName ($ tableName ));
100
+ $ primaryKeyFields = ['entity_id ' , 'attribute_id ' , 'store_id ' , 'value ' , 'source_id ' ];
101
+ $ setup ->getConnection ()->addIndex (
102
+ $ tableName ,
103
+ $ connection ->getIndexName ($ tableName , $ primaryKeyFields ),
104
+ $ primaryKeyFields ,
105
+ \Magento \Framework \DB \Adapter \AdapterInterface::INDEX_TYPE_PRIMARY
106
+ );
107
+ }
115
108
}
116
109
}
117
110
@@ -367,17 +360,21 @@ private function removeGroupPrice(SchemaSetupInterface $setup)
367
360
private function addPercentageValueColumn (SchemaSetupInterface $ setup )
368
361
{
369
362
$ connection = $ setup ->getConnection ();
370
- $ connection ->addColumn (
371
- $ setup ->getTable ('catalog_product_entity_tier_price ' ),
372
- 'percentage_value ' ,
373
- [
374
- 'type ' => \Magento \Framework \DB \Ddl \Table::TYPE_DECIMAL ,
375
- 'nullable ' => true ,
376
- 'length ' => '5,2 ' ,
377
- 'comment ' => 'Percentage value ' ,
378
- 'after ' => 'value '
379
- ]
380
- );
363
+ $ tableName = $ setup ->getTable ('catalog_product_entity_tier_price ' );
364
+
365
+ if (!$ connection ->tableColumnExists ($ tableName , 'percentage_value ' )) {
366
+ $ connection ->addColumn (
367
+ $ tableName ,
368
+ 'percentage_value ' ,
369
+ [
370
+ 'type ' => \Magento \Framework \DB \Ddl \Table::TYPE_DECIMAL ,
371
+ 'nullable ' => true ,
372
+ 'length ' => '5,2 ' ,
373
+ 'comment ' => 'Percentage value ' ,
374
+ 'after ' => 'value '
375
+ ]
376
+ );
377
+ }
381
378
}
382
379
383
380
/**
0 commit comments