1 | <?php |
||
2 | |||
3 | /** |
||
4 | * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
||
5 | * it under the terms of the GNU Lesser General Public License as published by |
||
6 | * the Free Software Foundation, either version 3 of the License, or |
||
7 | * (at your option) any later version. |
||
8 | * |
||
9 | * PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
12 | * GNU Lesser General Public License for more details. |
||
13 | * |
||
14 | * You should have received a copy of the GNU Lesser General Public License |
||
15 | * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
||
16 | * |
||
17 | * PHP version 5 |
||
18 | * |
||
19 | * @category Payone |
||
20 | * @package Payone_Magento2_Plugin |
||
21 | * @author FATCHIP GmbH <[email protected]> |
||
22 | * @copyright 2003 - 2016 Payone GmbH |
||
23 | * @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
||
24 | * @link http://www.payone.de |
||
25 | */ |
||
26 | |||
27 | namespace Payone\Core\Setup; |
||
28 | |||
29 | use Magento\Framework\DB\Ddl\Table; |
||
0 ignored issues
–
show
|
|||
30 | use Magento\Framework\Setup\ModuleContextInterface; |
||
0 ignored issues
–
show
The type
Magento\Framework\Setup\ModuleContextInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
31 | use Magento\Framework\Setup\SchemaSetupInterface; |
||
0 ignored issues
–
show
The type
Magento\Framework\Setup\SchemaSetupInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
32 | use Magento\Framework\Setup\UpgradeSchemaInterface; |
||
0 ignored issues
–
show
The type
Magento\Framework\Setup\UpgradeSchemaInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
33 | use Payone\Core\Setup\Tables\Api; |
||
34 | use Payone\Core\Setup\Tables\CheckedAddresses; |
||
35 | use Payone\Core\Setup\Tables\PaymentBan; |
||
36 | use Payone\Core\Setup\Tables\Transactionstatus; |
||
37 | use Payone\Core\Setup\Tables\SavedPaymentData; |
||
38 | use Payone\Core\Setup\Tables\RatepayProfileConfig; |
||
39 | |||
40 | /** |
||
41 | * Magento script for updating the database after the initial installation |
||
42 | */ |
||
43 | class UpgradeSchema extends BaseSchema implements UpgradeSchemaInterface |
||
44 | { |
||
45 | /** |
||
46 | * Add new columns |
||
47 | * |
||
48 | * @param SchemaSetupInterface $setup |
||
49 | * @param ModuleContextInterface $context |
||
50 | * @return void |
||
51 | */ |
||
52 | protected function addNewColumns(SchemaSetupInterface $setup, ModuleContextInterface $context) |
||
53 | { |
||
54 | if (version_compare($context->getVersion(), '1.3.0', '<')) {// pre update version is lower than 1.3.0 |
||
55 | $this->addTable($setup, \Payone\Core\Setup\Tables\CheckedAddresses::getData()); |
||
56 | |||
57 | $setup->getConnection('checkout')->addColumn( |
||
58 | $setup->getTable('quote_address'), |
||
59 | 'payone_addresscheck_score', |
||
60 | [ |
||
61 | 'type' => Table::TYPE_TEXT, |
||
62 | 'length' => 1, |
||
63 | 'nullable' => false, |
||
64 | 'default' => '', |
||
65 | 'comment' => 'AddressCheck Person Status Score (G, Y, R)' |
||
66 | ] |
||
67 | ); |
||
68 | $setup->getConnection('checkout')->addColumn( |
||
69 | $setup->getTable('quote_address'), |
||
70 | 'payone_protect_score', |
||
71 | [ |
||
72 | 'type' => Table::TYPE_TEXT, |
||
73 | 'length' => 1, |
||
74 | 'nullable' => false, |
||
75 | 'default' => '', |
||
76 | 'comment' => 'Consumerscore Status Score (G, Y, R)' |
||
77 | ] |
||
78 | ); |
||
79 | } |
||
80 | if (!$setup->getConnection()->tableColumnExists($setup->getTable(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS), 'has_been_handled')) { |
||
81 | $setup->getConnection()->addColumn( |
||
82 | $setup->getTable(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS), |
||
83 | 'has_been_handled', |
||
84 | [ |
||
85 | 'type' => Table::TYPE_SMALLINT, |
||
86 | 'length' => null, |
||
87 | 'nullable' => false, |
||
88 | 'default' => 1, |
||
89 | 'comment' => 'Has the status been handled already' |
||
90 | ] |
||
91 | ); |
||
92 | } |
||
93 | if (!$setup->getConnection()->tableColumnExists($setup->getTable(CheckedAddresses::TABLE_CHECKED_ADDRESSES), 'checktype')) { |
||
94 | $setup->getConnection()->addColumn( |
||
95 | $setup->getTable(CheckedAddresses::TABLE_CHECKED_ADDRESSES), |
||
96 | 'checktype', |
||
97 | [ |
||
98 | 'type' => Table::TYPE_TEXT, |
||
99 | 'length' => 16, |
||
100 | 'nullable' => false, |
||
101 | 'default' => '', |
||
102 | 'comment' => 'Checktype used' |
||
103 | ] |
||
104 | ); |
||
105 | } |
||
106 | |||
107 | if (!$setup->getConnection()->tableColumnExists($setup->getTable(CheckedAddresses::TABLE_CHECKED_ADDRESSES), 'score')) { |
||
108 | $setup->getConnection()->addColumn( |
||
109 | $setup->getTable(CheckedAddresses::TABLE_CHECKED_ADDRESSES), |
||
110 | 'score', |
||
111 | [ |
||
112 | 'type' => Table::TYPE_TEXT, |
||
113 | 'length' => 16, |
||
114 | 'nullable' => false, |
||
115 | 'default' => '', |
||
116 | 'comment' => 'Score' |
||
117 | ] |
||
118 | ); |
||
119 | } |
||
120 | if (!$setup->getConnection()->tableColumnExists($setup->getTable(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS), 'clearing_bankcity')) { |
||
121 | $setup->getConnection()->addColumn( |
||
122 | $setup->getTable(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS), |
||
123 | 'clearing_bankcity', |
||
124 | [ |
||
125 | 'type' => Table::TYPE_TEXT, |
||
126 | 'length' => 64, |
||
127 | 'nullable' => false, |
||
128 | 'default' => '', |
||
129 | 'comment' => 'Clearing bank country', |
||
130 | 'after' => 'clearing_bankiban', |
||
131 | ] |
||
132 | ); |
||
133 | } |
||
134 | if (!$setup->getConnection()->tableColumnExists($setup->getTable(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS), 'clearing_bankcountry')) { |
||
135 | $setup->getConnection()->addColumn( |
||
136 | $setup->getTable(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS), |
||
137 | 'clearing_bankcountry', |
||
138 | [ |
||
139 | 'type' => Table::TYPE_TEXT, |
||
140 | 'length' => 32, |
||
141 | 'nullable' => false, |
||
142 | 'default' => '', |
||
143 | 'comment' => 'Clearing bank country', |
||
144 | 'after' => 'clearing_bankiban', |
||
145 | ] |
||
146 | ); |
||
147 | } |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * Add new tables |
||
152 | * |
||
153 | * @param SchemaSetupInterface $setup |
||
154 | * @param ModuleContextInterface $context |
||
155 | * @return void |
||
156 | */ |
||
157 | protected function addNewTables(SchemaSetupInterface $setup, ModuleContextInterface $context) |
||
158 | { |
||
159 | if (!$setup->getConnection()->isTableExists($setup->getTable(PaymentBan::TABLE_PAYMENT_BAN))) { |
||
160 | $this->addTable($setup, PaymentBan::getData()); |
||
161 | } |
||
162 | if (!$setup->getConnection()->isTableExists($setup->getTable(SavedPaymentData::TABLE_SAVED_PAYMENT_DATA))) { |
||
163 | $this->addTable($setup, SavedPaymentData::getData()); |
||
164 | } |
||
165 | if (!$setup->getConnection()->isTableExists($setup->getTable(RatepayProfileConfig::TABLE_RATEPAY_PROFILE_CONFIG))) { |
||
166 | $this->addTable($setup, RatepayProfileConfig::getData()); |
||
167 | } |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * Modify already existing columns |
||
172 | * |
||
173 | * @param SchemaSetupInterface $setup |
||
174 | * @param ModuleContextInterface $context |
||
175 | * @return void |
||
176 | */ |
||
177 | protected function modifyColumns(SchemaSetupInterface $setup, ModuleContextInterface $context) |
||
178 | { |
||
179 | if (version_compare($context->getVersion(), '2.3.0', '<=')) { |
||
180 | $setup->getConnection()->modifyColumn( |
||
181 | $setup->getTable('payone_protocol_api'), |
||
182 | 'mid', ['type' => Table::TYPE_INTEGER, 'default' => '0'] |
||
183 | ); |
||
184 | $setup->getConnection()->modifyColumn( |
||
185 | $setup->getTable('payone_protocol_api'), |
||
186 | 'aid', ['type' => Table::TYPE_INTEGER, 'default' => '0'] |
||
187 | ); |
||
188 | $setup->getConnection()->modifyColumn( |
||
189 | $setup->getTable('payone_protocol_api'), |
||
190 | 'portalid', ['type' => Table::TYPE_INTEGER, 'default' => '0'] |
||
191 | ); |
||
192 | } |
||
193 | |||
194 | if (version_compare($context->getVersion(), '2.5.1', '<')) { |
||
195 | $setup->getConnection()->modifyColumn( |
||
196 | $setup->getTable('payone_protocol_transactionstatus'), |
||
197 | 'aid', |
||
198 | [ |
||
199 | 'type' => Table::TYPE_INTEGER, |
||
200 | 'unsigned' => true, |
||
201 | 'default' => '0' |
||
202 | ] |
||
203 | ); |
||
204 | $setup->getConnection()->modifyColumn( |
||
205 | $setup->getTable('payone_protocol_transactionstatus'), |
||
206 | 'portalid', |
||
207 | [ |
||
208 | 'type' => Table::TYPE_INTEGER, |
||
209 | 'unsigned' => true, |
||
210 | 'default' => '0' |
||
211 | ] |
||
212 | ); |
||
213 | } |
||
214 | |||
215 | if (version_compare($context->getVersion(), '2.5.2', '<')) { |
||
216 | // Magento 2.3.0 changed Table::TYPE_FLOAT to have no decimals.. so type has to be changed |
||
217 | $setup->getConnection()->modifyColumn( |
||
218 | $setup->getTable(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS), |
||
219 | 'price', ['type' => Table::TYPE_DECIMAL, 'length' => '20,4', 'default' => '0'] |
||
220 | ); |
||
221 | $setup->getConnection()->modifyColumn( |
||
222 | $setup->getTable(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS), |
||
223 | 'balance', ['type' => Table::TYPE_DECIMAL, 'length' => '20,4', 'default' => '0'] |
||
224 | ); |
||
225 | $setup->getConnection()->modifyColumn( |
||
226 | $setup->getTable(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS), |
||
227 | 'receivable', ['type' => Table::TYPE_DECIMAL, 'length' => '20,4', 'default' => '0'] |
||
228 | ); |
||
229 | } |
||
230 | |||
231 | if (version_compare($context->getVersion(), '3.4.2', '<')) { |
||
232 | $setup->getConnection()->modifyColumn( |
||
233 | $setup->getTable(RatepayProfileConfig::TABLE_RATEPAY_PROFILE_CONFIG), |
||
234 | 'month_allowed', ['type' => Table::TYPE_TEXT, 'length' => '255', 'default' => null] |
||
235 | ); |
||
236 | } |
||
237 | } |
||
238 | |||
239 | /** |
||
240 | * Add indexes to speed up certain calls |
||
241 | * |
||
242 | * @param SchemaSetupInterface $setup |
||
243 | * @param ModuleContextInterface $context |
||
244 | * @return void |
||
245 | */ |
||
246 | protected function addIndexes(SchemaSetupInterface $setup, ModuleContextInterface $context) |
||
247 | { |
||
248 | if (version_compare($context->getVersion(), '2.3.1', '<=')) { |
||
249 | $connection = $setup->getConnection(); |
||
250 | |||
251 | $protocolApiTable = $setup->getTable($connection->getTableName(Api::TABLE_PROTOCOL_API)); |
||
252 | $connection->addIndex($protocolApiTable, $connection->getIndexName($protocolApiTable, 'txid'), 'txid'); |
||
253 | |||
254 | $transactionStatusTable = $setup->getTable($connection->getTableName(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS)); |
||
255 | $connection->addIndex($transactionStatusTable, $connection->getIndexName($transactionStatusTable, 'txid'), 'txid'); |
||
256 | $connection->addIndex($transactionStatusTable, $connection->getIndexName($transactionStatusTable, 'customerid'), 'customerid'); |
||
257 | } |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * Upgrade method |
||
262 | * |
||
263 | * @param SchemaSetupInterface $setup |
||
264 | * @param ModuleContextInterface $context |
||
265 | * @return void |
||
266 | */ |
||
267 | public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context) |
||
268 | { |
||
269 | $this->addNewTables($setup, $context); |
||
270 | $this->addNewColumns($setup, $context); |
||
271 | $this->modifyColumns($setup, $context); |
||
272 | $this->addIndexes($setup, $context); |
||
273 | } |
||
274 | } |
||
275 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths