7
7
use Magento \Framework \Setup \UpgradeSchemaInterface ;
8
8
use Magento \Framework \Setup \ModuleContextInterface ;
9
9
use Magento \Framework \Setup \SchemaSetupInterface ;
10
+ use Magento \Framework \DB \Adapter \AdapterInterface ;
10
11
11
12
/**
12
13
* @codeCoverageIgnore
@@ -53,5 +54,46 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
53
54
54
55
$ installer ->endSetup ();
55
56
}
57
+ if (version_compare ($ context ->getVersion (), '2.0.7 ' , '< ' )) {
58
+ $ connection = $ installer ->getConnection ();
59
+ $ this ->addColumnBaseGrandTotal ($ installer );
60
+ $ this ->addIndexBaseGrandTotal ($ connection , $ installer );
61
+ }
62
+ }
63
+
64
+ /**
65
+ * @param SchemaSetupInterface $installer
66
+ * @return void
67
+ */
68
+ private function addColumnBaseGrandTotal (SchemaSetupInterface $ installer )
69
+ {
70
+ $ connection = $ installer ->getConnection ();
71
+ $ connection ->addColumn (
72
+ $ installer ->getTable ('sales_invoice_grid ' ),
73
+ 'base_grand_total ' ,
74
+ [
75
+ 'type ' => \Magento \Framework \DB \Ddl \Table::TYPE_DECIMAL ,
76
+ 'unsigned ' => true ,
77
+ 'nullable ' => true ,
78
+ 'default ' => '0.0000 ' ,
79
+ 'length ' => '12,4 ' ,
80
+ 'comment ' => 'Base Grand Total ' ,
81
+ 'after ' => 'grand_total '
82
+ ]
83
+ );
84
+ }
85
+
86
+ /**
87
+ * @param AdapterInterface $connection
88
+ * @param SchemaSetupInterface $installer
89
+ * @return void
90
+ */
91
+ private function addIndexBaseGrandTotal (AdapterInterface $ connection , SchemaSetupInterface $ installer )
92
+ {
93
+ $ connection ->addIndex (
94
+ $ installer ->getTable ('sales_invoice_grid ' ),
95
+ $ installer ->getIdxName ('sales_invoice_grid ' , ['base_grand_total ' ]),
96
+ ['base_grand_total ' ]
97
+ );
56
98
}
57
- }
99
+ }
0 commit comments