Skip to content

Commit a08f378

Browse files
author
George Schiopu
committed
MAGETWO-83202: code refactoring, separate into different methods #10395
Signed-off-by: George Schiopu <[email protected]>
1 parent ba224b4 commit a08f378

File tree

2 files changed

+60
-36
lines changed

2 files changed

+60
-36
lines changed

app/code/Magento/Quote/Setup/UpgradeSchema.php

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ class UpgradeSchema implements UpgradeSchemaInterface
2626
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
2727
{
2828
$setup->startSetup();
29-
3029
if (version_compare($context->getVersion(), '2.0.1', '<')) {
3130
$setup->getConnection(self::$connectionName)->addIndex(
3231
$setup->getTable('quote_id_mask', self::$connectionName),
3332
$setup->getIdxName('quote_id_mask', ['masked_id'], '', self::$connectionName),
3433
['masked_id']
3534
);
3635
}
37-
3836
if (version_compare($context->getVersion(), '2.0.2', '<')) {
3937
$setup->getConnection(self::$connectionName)->changeColumn(
4038
$setup->getTable('quote_address', self::$connectionName),
@@ -101,34 +99,51 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
10199
);
102100
}
103101
if (version_compare($context->getVersion(), '2.0.7', '<')) {
104-
$connection = $setup->getConnection(self::$connectionName);
105-
$connection->modifyColumn(
106-
$setup->getTable('quote_address', self::$connectionName),
107-
'telephone',
108-
['type' => Table::TYPE_TEXT, 'length' => 255]
109-
)->modifyColumn(
110-
$setup->getTable('quote_address', self::$connectionName),
111-
'fax',
112-
['type' => Table::TYPE_TEXT, 'length' => 255]
113-
)->modifyColumn(
114-
$setup->getTable('quote_address', self::$connectionName),
115-
'region',
116-
['type' => Table::TYPE_TEXT, 'length' => 255]
117-
)->modifyColumn(
118-
$setup->getTable('quote_address', self::$connectionName),
119-
'city',
120-
['type' => Table::TYPE_TEXT, 'length' => 255]
121-
);
102+
$this->expandQuoteAddressFields($setup);
122103
}
123104
if (version_compare($context->getVersion(), '2.0.8', '<')) {
124-
$connection = $setup->getConnection(self::$connectionName);
125-
$connection->modifyColumn(
126-
$setup->getTable('quote', self::$connectionName),
127-
'remote_ip',
128-
['type' => Table::TYPE_TEXT, 'length' => 45]
129-
);
105+
$this->expandRemoteIpField($setup);
130106
}
131-
132107
$setup->endSetup();
133108
}
109+
110+
/**
111+
* @param SchemaSetupInterface $setup
112+
* @return void
113+
*/
114+
private function expandRemoteIpField(SchemaSetupInterface $setup)
115+
{
116+
$connection = $setup->getConnection(self::$connectionName);
117+
$connection->modifyColumn(
118+
$setup->getTable('quote', self::$connectionName),
119+
'remote_ip',
120+
['type' => Table::TYPE_TEXT, 'length' => 45]
121+
);
122+
}
123+
124+
/**
125+
* @param SchemaSetupInterface $setup
126+
* @return void
127+
*/
128+
private function expandQuoteAddressFields(SchemaSetupInterface $setup)
129+
{
130+
$connection = $setup->getConnection(self::$connectionName);
131+
$connection->modifyColumn(
132+
$setup->getTable('quote_address', self::$connectionName),
133+
'telephone',
134+
['type' => Table::TYPE_TEXT, 'length' => 255]
135+
)->modifyColumn(
136+
$setup->getTable('quote_address', self::$connectionName),
137+
'fax',
138+
['type' => Table::TYPE_TEXT, 'length' => 255]
139+
)->modifyColumn(
140+
$setup->getTable('quote_address', self::$connectionName),
141+
'region',
142+
['type' => Table::TYPE_TEXT, 'length' => 255]
143+
)->modifyColumn(
144+
$setup->getTable('quote_address', self::$connectionName),
145+
'city',
146+
['type' => Table::TYPE_TEXT, 'length' => 255]
147+
);
148+
}
134149
}

app/code/Magento/Sales/Setup/UpgradeSchema.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
107107
);
108108
}
109109
if (version_compare($context->getVersion(), '2.0.10', '<')) {
110-
$connection = $installer->getConnection(self::$connectionName);
111-
$connection->modifyColumn(
112-
$installer->getTable('sales_order', self::$connectionName),
113-
'remote_ip',
114-
[
115-
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
116-
'length' => 45
117-
]
118-
);
110+
$this->expandRemoteIpField($installer);
119111
}
120112
}
121113

@@ -152,4 +144,21 @@ private function addIndexBaseGrandTotal(SchemaSetupInterface $installer)
152144
['base_grand_total']
153145
);
154146
}
147+
148+
/**
149+
* @param SchemaSetupInterface $installer
150+
* @return void
151+
*/
152+
private function expandRemoteIpField(SchemaSetupInterface $installer)
153+
{
154+
$connection = $installer->getConnection(self::$connectionName);
155+
$connection->modifyColumn(
156+
$installer->getTable('sales_order', self::$connectionName),
157+
'remote_ip',
158+
[
159+
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
160+
'length' => 45
161+
]
162+
);
163+
}
155164
}

0 commit comments

Comments
 (0)