Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like OroCRMMagentoBundleInstaller often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use OroCRMMagentoBundleInstaller, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
33 | class OroCRMMagentoBundleInstaller implements |
||
34 | Installation, |
||
35 | ActivityExtensionAwareInterface, |
||
36 | IdentifierEventExtensionAwareInterface, |
||
37 | ExtendExtensionAwareInterface, |
||
38 | VisitEventAssociationExtensionAwareInterface, |
||
39 | ActivityListExtensionAwareInterface, |
||
40 | NoteExtensionAwareInterface |
||
41 | { |
||
42 | /** @var ActivityExtension */ |
||
43 | protected $activityExtension; |
||
44 | |||
45 | /** @var NoteExtension */ |
||
46 | protected $noteExtension; |
||
47 | |||
48 | /** @var IdentifierEventExtension */ |
||
49 | protected $identifierEventExtension; |
||
50 | |||
51 | /** @var ExtendExtension $extendExtension */ |
||
52 | protected $extendExtension; |
||
53 | |||
54 | /** @var VisitEventAssociationExtension */ |
||
55 | protected $visitExtension; |
||
56 | |||
57 | /** @var ActivityListExtension */ |
||
58 | protected $activityListExtension; |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | public function setActivityListExtension(ActivityListExtension $activityListExtension) |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | public function setActivityExtension(ActivityExtension $activityExtension) |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function setNoteExtension(NoteExtension $noteExtension) |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | public function setIdentifierEventExtension(IdentifierEventExtension $identifierEventExtension) |
||
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | public function setExtendExtension(ExtendExtension $extendExtension) |
||
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | public function setVisitEventAssociationExtension(VisitEventAssociationExtension $extension) |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | */ |
||
111 | public function getMigrationVersion() |
||
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | public function up(Schema $schema, QueryBag $queries) |
||
120 | { |
||
121 | /** Tables generation **/ |
||
122 | $this->createOrocrmMagentoRegionTable($schema); |
||
123 | $this->createOrocrmMagentoCartAddressTable($schema); |
||
124 | $this->createOrocrmMagentoOrderTable($schema); |
||
125 | $this->createOrocrmMagentoOrderCallsTable($schema); |
||
126 | $this->createOrocrmMagentoOrderEmailsTable($schema); |
||
127 | $this->createOrocrmMagentoCustomerGroupTable($schema); |
||
128 | $this->createOrocrmMagentoCustomerTable($schema); |
||
129 | $this->createOrocrmMagentoCartItemTable($schema); |
||
130 | $this->createOrocrmMagentoCustomerAddrTable($schema); |
||
131 | $this->createOrocrmMagentoCustAddrTypeTable($schema); |
||
132 | $this->createOrocrmMagentoOrderAddressTable($schema); |
||
133 | $this->createOrocrmMagentoOrderAddrTypeTable($schema); |
||
134 | $this->createOrocrmMagentoProductTable($schema); |
||
135 | $this->createOrocrmMagentoProdToWebsiteTable($schema); |
||
136 | $this->createOrocrmMagentoWebsiteTable($schema); |
||
137 | $this->createOrocrmMagentoCartTable($schema); |
||
138 | $this->createOrocrmMagentoCartCallsTable($schema); |
||
139 | $this->createOrocrmMagentoCartEmailsTable($schema); |
||
140 | $this->createOrocrmMagentoStoreTable($schema); |
||
141 | $this->createOrocrmMagentoCartStatusTable($schema); |
||
142 | $this->createOrocrmMagentoOrderItemsTable($schema); |
||
143 | $this->createOrocrmMagentoNewslSubscrTable($schema); |
||
144 | $this->updateIntegrationTransportTable($schema); |
||
145 | |||
146 | /** Foreign keys generation **/ |
||
147 | $this->addOrocrmMagentoCartAddressForeignKeys($schema); |
||
148 | $this->addOrocrmMagentoOrderForeignKeys($schema); |
||
149 | $this->addOrocrmMagentoOrderCallsForeignKeys($schema); |
||
150 | $this->addOrocrmMagentoOrderEmailsForeignKeys($schema); |
||
151 | $this->addOrocrmMagentoCustomerGroupForeignKeys($schema); |
||
152 | $this->addOrocrmMagentoCustomerForeignKeys($schema); |
||
153 | $this->addOrocrmMagentoCartItemForeignKeys($schema); |
||
154 | $this->addOrocrmMagentoCustomerAddrForeignKeys($schema); |
||
155 | $this->addOrocrmMagentoCustAddrTypeForeignKeys($schema); |
||
156 | $this->addOrocrmMagentoOrderAddressForeignKeys($schema); |
||
157 | $this->addOrocrmMagentoOrderAddrTypeForeignKeys($schema); |
||
158 | $this->addOrocrmMagentoProductForeignKeys($schema); |
||
159 | $this->addOrocrmMagentoProdToWebsiteForeignKeys($schema); |
||
160 | $this->addOrocrmMagentoWebsiteForeignKeys($schema); |
||
161 | $this->addOrocrmMagentoCartForeignKeys($schema); |
||
162 | $this->addOrocrmMagentoCartCallsForeignKeys($schema); |
||
163 | $this->addOrocrmMagentoCartEmailsForeignKeys($schema); |
||
164 | $this->addOrocrmMagentoStoreForeignKeys($schema); |
||
165 | $this->addOrocrmMagentoOrderItemsForeignKeys($schema); |
||
166 | $this->addOrocrmMagentoNewslSubscrForeignKeys($schema); |
||
167 | |||
168 | $this->addActivityAssociations($schema); |
||
169 | OrderActivityAssociation::addNoteAssociations($schema, $this->noteExtension); |
||
170 | $this->addIdentifierEventAssociations($schema); |
||
171 | InheritanceActivityTargets::addInheritanceTargets($schema, $this->activityListExtension); |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * Update oro_integration_transport table. |
||
176 | * |
||
177 | * @param Schema $schema |
||
178 | * @throws \Doctrine\DBAL\Schema\SchemaException |
||
179 | */ |
||
180 | protected function updateIntegrationTransportTable(Schema $schema) |
||
181 | { |
||
182 | IntegrationUpdate::updateOroIntegrationTransportTable($schema); |
||
183 | $table = $schema->getTable('oro_integration_transport'); |
||
184 | $table->addColumn('admin_url', 'string', ['notnull' => false, 'length' => 255]); |
||
185 | $table->addColumn('initial_sync_start_date', 'datetime', ['notnull' => false]); |
||
186 | $table->addColumn('extension_version', 'string', ['notnull' => false, 'length' => 255]); |
||
187 | $table->addColumn('magento_version', 'string', ['notnull' => false, 'length' => 255]); |
||
188 | $table->addColumn('guest_customer_sync', 'boolean', ['notnull' => false]); |
||
189 | $table->addColumn('mage_newsl_subscr_synced_to_id', 'integer', ['notnull' => false]); |
||
190 | } |
||
191 | |||
192 | /** |
||
193 | * Create orocrm_magento_region table |
||
194 | * |
||
195 | * @param Schema $schema |
||
196 | */ |
||
197 | protected function createOrocrmMagentoRegionTable(Schema $schema) |
||
198 | { |
||
199 | $table = $schema->createTable('orocrm_magento_region'); |
||
200 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
201 | $table->addColumn('combined_code', 'string', ['length' => 60, 'precision' => 0]); |
||
202 | $table->addColumn('code', 'string', ['length' => 32, 'precision' => 0]); |
||
203 | $table->addColumn('country_code', 'string', ['length' => 255, 'precision' => 0]); |
||
204 | $table->addColumn('region_id', 'integer', ['precision' => 0]); |
||
205 | $table->addColumn('name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
206 | $table->setPrimaryKey(['id']); |
||
207 | $table->addIndex(['region_id'], 'idx_region', []); |
||
208 | $table->addUniqueIndex(['combined_code'], 'unq_code'); |
||
209 | } |
||
210 | |||
211 | /** |
||
212 | * Create orocrm_magento_cart_address table |
||
213 | * |
||
214 | * @param Schema $schema |
||
215 | */ |
||
216 | protected function createOrocrmMagentoCartAddressTable(Schema $schema) |
||
217 | { |
||
218 | $table = $schema->createTable('orocrm_magento_cart_address'); |
||
219 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
220 | $table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]); |
||
221 | $table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]); |
||
222 | $table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
223 | $table->addColumn('label', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
224 | $table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
||
225 | $table->addColumn('street2', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
||
226 | $table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
227 | $table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
228 | $table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
229 | $table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
230 | $table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
231 | $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
232 | $table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
233 | $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
234 | $table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
235 | $table->addColumn('created', 'datetime', ['precision' => 0]); |
||
236 | $table->addColumn('updated', 'datetime', ['precision' => 0]); |
||
237 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
238 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
239 | $table->addIndex(['country_code'], 'IDX_6978F651F026BB7C', []); |
||
240 | $table->addIndex(['region_code'], 'IDX_6978F651AEB327AF', []); |
||
241 | $table->setPrimaryKey(['id']); |
||
242 | } |
||
243 | |||
244 | /** |
||
245 | * Create orocrm_magento_order table |
||
246 | * |
||
247 | * @param Schema $schema |
||
248 | */ |
||
249 | protected function createOrocrmMagentoOrderTable(Schema $schema) |
||
250 | { |
||
251 | $table = $schema->createTable('orocrm_magento_order'); |
||
252 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
253 | $table->addColumn('customer_id', 'integer', ['notnull' => false]); |
||
254 | $table->addColumn('store_id', 'integer', ['notnull' => false]); |
||
255 | $table->addColumn('cart_id', 'integer', ['notnull' => false]); |
||
256 | $table->addColumn('workflow_item_id', 'integer', ['notnull' => false]); |
||
257 | $table->addColumn('workflow_step_id', 'integer', ['notnull' => false]); |
||
258 | $table->addColumn('user_owner_id', 'integer', ['notnull' => false]); |
||
259 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
260 | $table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
||
261 | $table->addColumn('increment_id', 'string', ['length' => 60, 'precision' => 0]); |
||
262 | $table->addColumn('is_virtual', 'boolean', ['notnull' => false, 'precision' => 0]); |
||
263 | $table->addColumn('is_guest', 'boolean', ['notnull' => false, 'precision' => 0]); |
||
264 | $table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
265 | $table->addColumn('remote_ip', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
266 | $table->addColumn('store_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
267 | $table->addColumn('total_paid_amount', 'float', ['notnull' => false, 'precision' => 0]); |
||
268 | $table->addColumn( |
||
269 | 'total_invoiced_amount', |
||
270 | 'money', |
||
271 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
272 | ); |
||
273 | $table->addColumn( |
||
274 | 'total_refunded_amount', |
||
275 | 'money', |
||
276 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
277 | ); |
||
278 | $table->addColumn( |
||
279 | 'total_canceled_amount', |
||
280 | 'money', |
||
281 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
282 | ); |
||
283 | $table->addColumn('notes', 'text', ['notnull' => false, 'precision' => 0]); |
||
284 | $table->addColumn('feedback', 'text', ['notnull' => false, 'precision' => 0]); |
||
285 | $table->addColumn('customer_email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
286 | $table->addColumn('currency', 'string', ['notnull' => false, 'length' => 10, 'precision' => 0]); |
||
287 | $table->addColumn('payment_method', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
288 | $table->addColumn('payment_details', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
289 | $table->addColumn( |
||
290 | 'subtotal_amount', |
||
291 | 'money', |
||
292 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
293 | ); |
||
294 | $table->addColumn( |
||
295 | 'shipping_amount', |
||
296 | 'money', |
||
297 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
298 | ); |
||
299 | $table->addColumn('shipping_method', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
300 | $table->addColumn( |
||
301 | 'tax_amount', |
||
302 | 'money', |
||
303 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
304 | ); |
||
305 | $table->addColumn( |
||
306 | 'discount_amount', |
||
307 | 'money', |
||
308 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
309 | ); |
||
310 | $table->addColumn( |
||
311 | 'discount_percent', |
||
312 | 'percent', |
||
313 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)'] |
||
314 | ); |
||
315 | $table->addColumn( |
||
316 | 'total_amount', |
||
317 | 'money', |
||
318 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
319 | ); |
||
320 | $table->addColumn('status', 'string', ['length' => 255, 'precision' => 0]); |
||
321 | $table->addColumn('created_at', 'datetime', ['precision' => 0]); |
||
322 | $table->addColumn('updated_at', 'datetime', ['precision' => 0]); |
||
323 | $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
324 | $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
325 | $table->addColumn('organization_id', 'integer', ['notnull' => false]); |
||
326 | $table->addColumn('coupon_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
327 | $table->addIndex(['customer_id'], 'IDX_4D09F3059395C3F3', []); |
||
328 | $table->addIndex(['store_id'], 'IDX_4D09F305B092A811', []); |
||
329 | $table->addIndex(['cart_id'], 'IDX_4D09F3051AD5CDBF', []); |
||
330 | $table->addUniqueIndex(['workflow_item_id'], 'UNIQ_4D09F3051023C4EE'); |
||
331 | $table->addIndex(['workflow_step_id'], 'IDX_4D09F30571FE882C', []); |
||
332 | $table->addIndex(['user_owner_id'], 'IDX_4D09F3059EB185F9', []); |
||
333 | $table->addIndex(['channel_id'], 'IDX_4D09F30572F5A1AA', []); |
||
334 | $table->addIndex(['data_channel_id'], 'IDX_4D09F305BDC09B73', []); |
||
335 | $table->addIndex(['organization_id'], 'IDX_4D09F30532C8A3DE', []); |
||
336 | $table->setPrimaryKey(['id']); |
||
337 | $table->addIndex(['created_at'], 'mageorder_created_idx', []); |
||
338 | $table->addUniqueIndex(['increment_id', 'channel_id'], 'unq_increment_id_channel_id'); |
||
339 | } |
||
340 | |||
341 | /** |
||
342 | * Create orocrm_magento_order_calls table |
||
343 | * |
||
344 | * @param Schema $schema |
||
345 | */ |
||
346 | View Code Duplication | protected function createOrocrmMagentoOrderCallsTable(Schema $schema) |
|
|
|||
347 | { |
||
348 | $table = $schema->createTable('orocrm_magento_order_calls'); |
||
349 | $table->addColumn('order_id', 'integer', []); |
||
350 | $table->addColumn('call_id', 'integer', []); |
||
351 | $table->addIndex(['order_id'], 'IDX_A885A348D9F6D38', []); |
||
352 | $table->addIndex(['call_id'], 'IDX_A885A3450A89B2C', []); |
||
353 | $table->setPrimaryKey(['order_id', 'call_id']); |
||
354 | } |
||
355 | |||
356 | /** |
||
357 | * Create orocrm_magento_order_emails table |
||
358 | * |
||
359 | * @param Schema $schema |
||
360 | */ |
||
361 | View Code Duplication | protected function createOrocrmMagentoOrderEmailsTable(Schema $schema) |
|
362 | { |
||
363 | $table = $schema->createTable('orocrm_magento_order_emails'); |
||
364 | $table->addColumn('order_id', 'integer', []); |
||
365 | $table->addColumn('email_id', 'integer', []); |
||
366 | $table->addIndex(['order_id'], 'IDX_10E2A9508D9F6D38', []); |
||
367 | $table->addIndex(['email_id'], 'IDX_10E2A950A832C1C9', []); |
||
368 | $table->setPrimaryKey(['order_id', 'email_id']); |
||
369 | } |
||
370 | |||
371 | /** |
||
372 | * Create orocrm_magento_customer_group table |
||
373 | * |
||
374 | * @param Schema $schema |
||
375 | */ |
||
376 | protected function createOrocrmMagentoCustomerGroupTable(Schema $schema) |
||
377 | { |
||
378 | $table = $schema->createTable('orocrm_magento_customer_group'); |
||
379 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
380 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
381 | $table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
||
382 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
383 | $table->addIndex(['channel_id'], 'IDX_71E09CA872F5A1AA', []); |
||
384 | $table->setPrimaryKey(['id']); |
||
385 | } |
||
386 | |||
387 | /** |
||
388 | * Create orocrm_magento_customer table |
||
389 | * |
||
390 | * @param Schema $schema |
||
391 | */ |
||
392 | protected function createOrocrmMagentoCustomerTable(Schema $schema) |
||
393 | { |
||
394 | $table = $schema->createTable('orocrm_magento_customer'); |
||
395 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
396 | $table->addColumn('website_id', 'integer', ['notnull' => false]); |
||
397 | $table->addColumn('store_id', 'integer', ['notnull' => false]); |
||
398 | $table->addColumn('customer_group_id', 'integer', ['notnull' => false]); |
||
399 | $table->addColumn('contact_id', 'integer', ['notnull' => false]); |
||
400 | $table->addColumn('account_id', 'integer', ['notnull' => false]); |
||
401 | $table->addColumn('user_owner_id', 'integer', ['notnull' => false]); |
||
402 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
403 | $table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
||
404 | $table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
405 | $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
406 | $table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
407 | $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
408 | $table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
409 | $table->addColumn('gender', 'string', ['notnull' => false, 'length' => 8, 'precision' => 0]); |
||
410 | $table->addColumn('birthday', 'date', ['notnull' => false, 'precision' => 0]); |
||
411 | $table->addColumn('email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
412 | $table->addColumn('created_at', 'datetime', ['precision' => 0]); |
||
413 | $table->addColumn('updated_at', 'datetime', ['precision' => 0]); |
||
414 | $table->addColumn('is_active', 'boolean', ['precision' => 0]); |
||
415 | $table->addColumn('vat', 'string', ['notnull' => false, 'length' => 255]); |
||
416 | $table->addColumn('lifetime', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
||
417 | $table->addColumn('currency', 'string', ['notnull' => false, 'length' => 10, 'precision' => 0]); |
||
418 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
419 | $table->addColumn('organization_id', 'integer', ['notnull' => false]); |
||
420 | $table->addColumn('rfm_recency', 'integer', ['notnull' => false]); |
||
421 | $table->addColumn('rfm_frequency', 'integer', ['notnull' => false]); |
||
422 | $table->addColumn('rfm_monetary', 'integer', ['notnull' => false]); |
||
423 | $table->addColumn('sync_state', 'integer', ['notnull' => false]); |
||
424 | $table->addColumn('password', 'string', ['notnull' => false, 'length' => 32]); |
||
425 | $table->addColumn('created_in', 'string', ['notnull' => false, 'length' => 255]); |
||
426 | $table->addColumn('is_confirmed', 'boolean', ['notnull' => false]); |
||
427 | $table->addColumn('is_guest', 'boolean', ['notnull' => true, 'default' => false]); |
||
428 | $table->addIndex(['website_id'], 'IDX_2A61EE7D18F45C82', []); |
||
429 | $table->addIndex(['store_id'], 'IDX_2A61EE7DB092A811', []); |
||
430 | $table->addIndex(['customer_group_id'], 'IDX_2A61EE7DD2919A68', []); |
||
431 | $table->addIndex(['contact_id'], 'IDX_2A61EE7DE7A1254A', []); |
||
432 | $table->addIndex(['account_id'], 'IDX_2A61EE7D9B6B5FBA', []); |
||
433 | $table->addIndex(['user_owner_id'], 'IDX_2A61EE7D9EB185F9', []); |
||
434 | $table->addIndex(['channel_id'], 'IDX_2A61EE7D72F5A1AA', []); |
||
435 | $table->addIndex(['data_channel_id'], 'IDX_2A61EE7DBDC09B73', []); |
||
436 | $table->addIndex(['organization_id'], 'IDX_2A61EE7D32C8A3DE', []); |
||
437 | $table->setPrimaryKey(['id']); |
||
438 | $table->addIndex(['first_name', 'last_name'], 'magecustomer_name_idx', []); |
||
439 | $table->addIndex(['last_name', 'first_name'], 'magecustomer_rev_name_idx', []); |
||
440 | $table->addIndex(['email'], 'magecustomer_email_guest_idx', []); |
||
441 | $table->addUniqueIndex(['origin_id', 'channel_id'], 'magecustomer_oid_cid_unq'); |
||
442 | } |
||
443 | |||
444 | /** |
||
445 | * Create orocrm_magento_cart_item table |
||
446 | * |
||
447 | * @param Schema $schema |
||
448 | */ |
||
449 | protected function createOrocrmMagentoCartItemTable(Schema $schema) |
||
450 | { |
||
451 | $table = $schema->createTable('orocrm_magento_cart_item'); |
||
452 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
453 | $table->addColumn('cart_id', 'integer', ['notnull' => false]); |
||
454 | $table->addColumn('product_id', 'integer', ['precision' => 0, 'unsigned' => true]); |
||
455 | $table->addColumn('parent_item_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
456 | $table->addColumn('free_shipping', 'string', ['length' => 255, 'precision' => 0]); |
||
457 | $table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
458 | $table->addColumn('tax_class_id', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
459 | $table->addColumn('description', 'text', ['notnull' => false, 'precision' => 0]); |
||
460 | $table->addColumn('is_virtual', 'boolean', ['precision' => 0]); |
||
461 | $table->addColumn( |
||
462 | 'custom_price', |
||
463 | 'money', |
||
464 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
465 | ); |
||
466 | $table->addColumn( |
||
467 | 'price_incl_tax', |
||
468 | 'money', |
||
469 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
470 | ); |
||
471 | $table->addColumn('row_total', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
||
472 | $table->addColumn('tax_amount', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
||
473 | $table->addColumn('product_type', 'string', ['length' => 255, 'precision' => 0]); |
||
474 | $table->addColumn('product_image_url', 'text', ['notnull' => false]); |
||
475 | $table->addColumn('product_url', 'text', ['notnull' => false]); |
||
476 | $table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0]); |
||
477 | $table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
||
478 | $table->addColumn('qty', 'float', ['precision' => 0]); |
||
479 | $table->addColumn('price', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
||
480 | $table->addColumn('discount_amount', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
||
481 | $table->addColumn('tax_percent', 'percent', ['precision' => 0, 'comment' => '(DC2Type:percent)']); |
||
482 | $table->addColumn('weight', 'float', ['notnull' => false, 'precision' => 0]); |
||
483 | $table->addColumn('createdAt', 'datetime', ['precision' => 0]); |
||
484 | $table->addColumn('updatedAt', 'datetime', ['precision' => 0]); |
||
485 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
486 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
487 | $table->addColumn('is_removed', 'boolean', ['notnull' => true, 'default' => false]); |
||
488 | $table->addColumn('owner_id', 'integer', ['notnull' => false]); |
||
489 | $table->addIndex(['cart_id'], 'IDX_A73DC8621AD5CDBF', []); |
||
490 | $table->addIndex(['owner_id'], 'IDX_A73DC8627E3C61F9', []); |
||
491 | $table->setPrimaryKey(['id']); |
||
492 | $table->addIndex(['origin_id'], 'magecartitem_origin_idx', []); |
||
493 | $table->addIndex(['sku'], 'magecartitem_sku_idx', []); |
||
494 | } |
||
495 | |||
496 | /** |
||
497 | * Create orocrm_magento_customer_addr table |
||
498 | * |
||
499 | * @param Schema $schema |
||
500 | */ |
||
501 | protected function createOrocrmMagentoCustomerAddrTable(Schema $schema) |
||
502 | { |
||
503 | $table = $schema->createTable('orocrm_magento_customer_addr'); |
||
504 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
505 | $table->addColumn('owner_id', 'integer', ['notnull' => false]); |
||
506 | $table->addColumn('related_contact_address_id', 'integer', ['notnull' => false]); |
||
507 | $table->addColumn('related_contact_phone_id', 'integer', ['notnull' => false]); |
||
508 | $table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]); |
||
509 | $table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]); |
||
510 | $table->addColumn('label', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
511 | $table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
||
512 | $table->addColumn('street2', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
||
513 | $table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
514 | $table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
515 | $table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
516 | $table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
517 | $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
518 | $table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
519 | $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
520 | $table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
521 | $table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
522 | $table->addColumn('is_primary', 'boolean', ['notnull' => false, 'precision' => 0]); |
||
523 | $table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
524 | $table->addColumn('created', 'datetime', ['precision' => 0]); |
||
525 | $table->addColumn('updated', 'datetime', ['precision' => 0]); |
||
526 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
527 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
528 | $table->addColumn('sync_state', 'integer', ['notnull' => false]); |
||
529 | $table->addIndex(['owner_id'], 'IDX_1E239D647E3C61F9', []); |
||
530 | $table->addUniqueIndex(['related_contact_address_id'], 'UNIQ_1E239D648137CB7B'); |
||
531 | $table->addUniqueIndex(['related_contact_phone_id'], 'UNIQ_1E239D64E3694F65'); |
||
532 | $table->addIndex(['country_code'], 'IDX_1E239D64F026BB7C', []); |
||
533 | $table->addIndex(['region_code'], 'IDX_1E239D64AEB327AF', []); |
||
534 | $table->setPrimaryKey(['id']); |
||
535 | } |
||
536 | |||
537 | /** |
||
538 | * Create orocrm_magento_cust_addr_type table |
||
539 | * |
||
540 | * @param Schema $schema |
||
541 | */ |
||
542 | View Code Duplication | protected function createOrocrmMagentoCustAddrTypeTable(Schema $schema) |
|
543 | { |
||
544 | $table = $schema->createTable('orocrm_magento_cust_addr_type'); |
||
545 | $table->addColumn('customer_address_id', 'integer', []); |
||
546 | $table->addColumn('type_name', 'string', ['length' => 16]); |
||
547 | $table->addIndex(['customer_address_id'], 'IDX_308A31F187EABF7', []); |
||
548 | $table->addIndex(['type_name'], 'IDX_308A31F1892CBB0E', []); |
||
549 | $table->setPrimaryKey(['customer_address_id', 'type_name']); |
||
550 | } |
||
551 | |||
552 | /** |
||
553 | * Create orocrm_magento_order_address table |
||
554 | * |
||
555 | * @param Schema $schema |
||
556 | */ |
||
557 | protected function createOrocrmMagentoOrderAddressTable(Schema $schema) |
||
558 | { |
||
559 | $table = $schema->createTable('orocrm_magento_order_address'); |
||
560 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
561 | $table->addColumn('owner_id', 'integer', ['notnull' => false]); |
||
562 | $table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]); |
||
563 | $table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]); |
||
564 | $table->addColumn('fax', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
565 | $table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
566 | $table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
||
567 | $table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
568 | $table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
569 | $table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
570 | $table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
571 | $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
572 | $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
573 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
574 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
575 | $table->addIndex(['owner_id'], 'IDX_E31C6DEC7E3C61F9', []); |
||
576 | $table->addIndex(['country_code'], 'IDX_E31C6DECF026BB7C', []); |
||
577 | $table->addIndex(['region_code'], 'IDX_E31C6DECAEB327AF', []); |
||
578 | $table->setPrimaryKey(['id']); |
||
579 | } |
||
580 | |||
581 | /** |
||
582 | * Create orocrm_magento_order_addr_type table |
||
583 | * |
||
584 | * @param Schema $schema |
||
585 | */ |
||
586 | View Code Duplication | protected function createOrocrmMagentoOrderAddrTypeTable(Schema $schema) |
|
587 | { |
||
588 | $table = $schema->createTable('orocrm_magento_order_addr_type'); |
||
589 | $table->addColumn('order_address_id', 'integer', []); |
||
590 | $table->addColumn('type_name', 'string', ['length' => 16]); |
||
591 | $table->addIndex(['order_address_id'], 'IDX_E927A18F466D5220', []); |
||
592 | $table->addIndex(['type_name'], 'IDX_E927A18F892CBB0E', []); |
||
593 | $table->setPrimaryKey(['order_address_id', 'type_name']); |
||
594 | } |
||
595 | |||
596 | /** |
||
597 | * Create orocrm_magento_product table |
||
598 | * |
||
599 | * @param Schema $schema |
||
600 | */ |
||
601 | protected function createOrocrmMagentoProductTable(Schema $schema) |
||
623 | |||
624 | /** |
||
625 | * Create orocrm_magento_prod_to_website table |
||
626 | * |
||
627 | * @param Schema $schema |
||
628 | */ |
||
629 | View Code Duplication | protected function createOrocrmMagentoProdToWebsiteTable(Schema $schema) |
|
630 | { |
||
631 | $table = $schema->createTable('orocrm_magento_prod_to_website'); |
||
632 | $table->addColumn('product_id', 'integer', []); |
||
633 | $table->addColumn('website_id', 'integer', []); |
||
634 | $table->addIndex(['product_id'], 'IDX_9BB836554584665A', []); |
||
635 | $table->addIndex(['website_id'], 'IDX_9BB8365518F45C82', []); |
||
636 | $table->setPrimaryKey(['product_id', 'website_id']); |
||
637 | } |
||
638 | |||
639 | /** |
||
640 | * Create orocrm_magento_website table |
||
641 | * |
||
642 | * @param Schema $schema |
||
643 | */ |
||
644 | protected function createOrocrmMagentoWebsiteTable(Schema $schema) |
||
645 | { |
||
646 | $table = $schema->createTable('orocrm_magento_website'); |
||
647 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
648 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
649 | $table->addColumn('website_code', 'string', ['length' => 32, 'precision' => 0]); |
||
650 | $table->addColumn('website_name', 'string', ['length' => 255, 'precision' => 0]); |
||
651 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
652 | $table->addColumn('sort_order', 'integer', ['notnull' => false]); |
||
653 | $table->addColumn('is_default', 'boolean', ['notnull' => false]); |
||
654 | $table->addColumn('default_group_id', 'integer', ['notnull' => false]); |
||
655 | $table->addIndex(['channel_id'], 'IDX_CE3270C872F5A1AA', []); |
||
656 | $table->setPrimaryKey(['id']); |
||
657 | $table->addIndex(['website_name'], 'orocrm_magento_website_name_idx', []); |
||
658 | $table->addUniqueIndex(['website_code', 'origin_id', 'channel_id'], 'unq_site_idx'); |
||
659 | } |
||
660 | |||
661 | /** |
||
662 | * Create orocrm_magento_cart table |
||
663 | * |
||
664 | * @param Schema $schema |
||
665 | */ |
||
666 | protected function createOrocrmMagentoCartTable(Schema $schema) |
||
667 | { |
||
668 | $table = $schema->createTable('orocrm_magento_cart'); |
||
669 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
670 | $table->addColumn('customer_id', 'integer', ['notnull' => false]); |
||
671 | $table->addColumn('store_id', 'integer', ['notnull' => false]); |
||
672 | $table->addColumn('shipping_address_id', 'integer', ['notnull' => false]); |
||
673 | $table->addColumn('billing_address_id', 'integer', ['notnull' => false]); |
||
674 | $table->addColumn('status_name', 'string', ['notnull' => false, 'length' => 32]); |
||
675 | $table->addColumn('opportunity_id', 'integer', ['notnull' => false]); |
||
676 | $table->addColumn('workflow_item_id', 'integer', ['notnull' => false]); |
||
677 | $table->addColumn('workflow_step_id', 'integer', ['notnull' => false]); |
||
678 | $table->addColumn('user_owner_id', 'integer', ['notnull' => false]); |
||
679 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
680 | $table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
||
681 | $table->addColumn('items_qty', 'float', ['precision' => 0]); |
||
682 | $table->addColumn('items_count', 'integer', ['precision' => 0, 'unsigned' => true]); |
||
683 | $table->addColumn('base_currency_code', 'string', ['length' => 32, 'precision' => 0]); |
||
684 | $table->addColumn('store_currency_code', 'string', ['length' => 32, 'precision' => 0]); |
||
685 | $table->addColumn('quote_currency_code', 'string', ['length' => 32, 'precision' => 0]); |
||
686 | $table->addColumn('store_to_base_rate', 'float', ['precision' => 0]); |
||
687 | $table->addColumn('store_to_quote_rate', 'float', ['notnull' => false, 'precision' => 0]); |
||
688 | $table->addColumn('email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
689 | $table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
690 | $table->addColumn('is_guest', 'boolean', ['precision' => 0]); |
||
691 | $table->addColumn('payment_details', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
692 | $table->addColumn('notes', 'text', ['notnull' => false, 'precision' => 0]); |
||
693 | $table->addColumn('status_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
694 | $table->addColumn('sub_total', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
||
695 | $table->addColumn( |
||
696 | 'grand_total', |
||
697 | 'money', |
||
698 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
699 | ); |
||
700 | $table->addColumn( |
||
701 | 'tax_amount', |
||
702 | 'money', |
||
703 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
704 | ); |
||
705 | $table->addColumn('createdAt', 'datetime', ['precision' => 0]); |
||
706 | $table->addColumn('updatedAt', 'datetime', ['precision' => 0]); |
||
707 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
708 | $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
709 | $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
710 | $table->addColumn('organization_id', 'integer', ['notnull' => false]); |
||
711 | $table->addIndex(['customer_id'], 'IDX_96661A809395C3F3', []); |
||
712 | $table->addIndex(['store_id'], 'IDX_96661A80B092A811', []); |
||
713 | $table->addIndex(['shipping_address_id'], 'IDX_96661A804D4CFF2B', []); |
||
714 | $table->addIndex(['billing_address_id'], 'IDX_96661A8079D0C0E4', []); |
||
715 | $table->addIndex(['status_name'], 'IDX_96661A806625D392', []); |
||
716 | $table->addIndex(['opportunity_id'], 'IDX_96661A809A34590F', []); |
||
717 | $table->addUniqueIndex(['workflow_item_id'], 'UNIQ_96661A801023C4EE'); |
||
718 | $table->addIndex(['workflow_step_id'], 'IDX_96661A8071FE882C', []); |
||
719 | $table->addIndex(['user_owner_id'], 'IDX_96661A809EB185F9', []); |
||
720 | $table->addIndex(['channel_id'], 'IDX_96661A8072F5A1AA', []); |
||
721 | $table->addIndex(['data_channel_id'], 'IDX_96661A80BDC09B73', []); |
||
722 | $table->addIndex(['organization_id'], 'IDX_96661A8032C8A3DE', []); |
||
723 | $table->setPrimaryKey(['id']); |
||
724 | $table->addIndex(['origin_id'], 'magecart_origin_idx', []); |
||
725 | $table->addIndex(['updatedAt'], 'magecart_updated_idx', []); |
||
726 | $table->addUniqueIndex(['origin_id', 'channel_id'], 'unq_cart_origin_id_channel_id'); |
||
727 | } |
||
728 | |||
729 | /** |
||
730 | * Create orocrm_magento_cart_calls table |
||
731 | * |
||
732 | * @param Schema $schema |
||
733 | */ |
||
734 | View Code Duplication | protected function createOrocrmMagentoCartCallsTable(Schema $schema) |
|
735 | { |
||
736 | $table = $schema->createTable('orocrm_magento_cart_calls'); |
||
737 | $table->addColumn('cart_id', 'integer', []); |
||
738 | $table->addColumn('call_id', 'integer', []); |
||
739 | $table->addIndex(['cart_id'], 'IDX_83A847751AD5CDBF', []); |
||
740 | $table->addIndex(['call_id'], 'IDX_83A8477550A89B2C', []); |
||
741 | $table->setPrimaryKey(['cart_id', 'call_id']); |
||
742 | } |
||
743 | |||
744 | /** |
||
745 | * Create orocrm_magento_cart_emails table |
||
746 | * |
||
747 | * @param Schema $schema |
||
748 | */ |
||
749 | View Code Duplication | protected function createOrocrmMagentoCartEmailsTable(Schema $schema) |
|
750 | { |
||
751 | $table = $schema->createTable('orocrm_magento_cart_emails'); |
||
752 | $table->addColumn('cart_id', 'integer', []); |
||
753 | $table->addColumn('email_id', 'integer', []); |
||
754 | $table->addIndex(['cart_id'], 'IDX_11B0F84B1AD5CDBF', []); |
||
755 | $table->addIndex(['email_id'], 'IDX_11B0F84BA832C1C9', []); |
||
756 | $table->setPrimaryKey(['cart_id', 'email_id']); |
||
757 | } |
||
758 | |||
759 | /** |
||
760 | * Create orocrm_magento_store table |
||
761 | * |
||
762 | * @param Schema $schema |
||
763 | */ |
||
764 | View Code Duplication | protected function createOrocrmMagentoStoreTable(Schema $schema) |
|
765 | { |
||
766 | $table = $schema->createTable('orocrm_magento_store'); |
||
767 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
768 | $table->addColumn('website_id', 'integer', []); |
||
769 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
770 | $table->addColumn('store_code', 'string', ['length' => 32, 'precision' => 0]); |
||
771 | $table->addColumn('store_name', 'string', ['length' => 255, 'precision' => 0]); |
||
772 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
773 | $table->addIndex(['website_id'], 'IDX_477738EA18F45C82', []); |
||
774 | $table->addIndex(['channel_id'], 'IDX_477738EA72F5A1AA', []); |
||
775 | $table->setPrimaryKey(['id']); |
||
776 | $table->addUniqueIndex(['store_code', 'channel_id'], 'unq_code_channel_id'); |
||
777 | } |
||
778 | |||
779 | /** |
||
780 | * Create orocrm_magento_cart_status table |
||
781 | * |
||
782 | * @param Schema $schema |
||
783 | */ |
||
784 | protected function createOrocrmMagentoCartStatusTable(Schema $schema) |
||
785 | { |
||
786 | $table = $schema->createTable('orocrm_magento_cart_status'); |
||
787 | $table->addColumn('name', 'string', ['length' => 32, 'precision' => 0]); |
||
788 | $table->addColumn('label', 'string', ['length' => 255, 'precision' => 0]); |
||
789 | $table->addUniqueIndex(['label'], 'UNIQ_26317505EA750E8'); |
||
790 | $table->setPrimaryKey(['name']); |
||
791 | } |
||
792 | |||
793 | /** |
||
794 | * Create orocrm_magento_order_items table |
||
795 | * |
||
796 | * @param Schema $schema |
||
797 | */ |
||
798 | protected function createOrocrmMagentoOrderItemsTable(Schema $schema) |
||
799 | { |
||
800 | $table = $schema->createTable('orocrm_magento_order_items'); |
||
801 | $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
||
802 | $table->addColumn('order_id', 'integer', ['notnull' => false]); |
||
803 | $table->addColumn('product_type', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
||
804 | $table->addColumn('product_options', 'text', ['notnull' => false, 'precision' => 0]); |
||
805 | $table->addColumn('is_virtual', 'boolean', ['notnull' => false, 'precision' => 0]); |
||
806 | $table->addColumn( |
||
807 | 'original_price', |
||
808 | 'money', |
||
809 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
810 | ); |
||
811 | $table->addColumn( |
||
812 | 'discount_percent', |
||
813 | 'percent', |
||
814 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)'] |
||
815 | ); |
||
816 | $table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
||
817 | $table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0]); |
||
818 | $table->addColumn('qty', 'float', ['precision' => 0]); |
||
819 | $table->addColumn('price', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
||
820 | $table->addColumn('weight', 'float', ['notnull' => false, 'precision' => 0]); |
||
821 | $table->addColumn( |
||
822 | 'tax_percent', |
||
823 | 'percent', |
||
824 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)'] |
||
825 | ); |
||
826 | $table->addColumn( |
||
827 | 'tax_amount', |
||
828 | 'money', |
||
829 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
830 | ); |
||
831 | $table->addColumn( |
||
832 | 'discount_amount', |
||
833 | 'money', |
||
834 | ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
||
835 | ); |
||
836 | $table->addColumn('row_total', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
||
837 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
838 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
839 | $table->addColumn('owner_id', 'integer', ['notnull' => false]); |
||
840 | $table->addIndex(['order_id'], 'IDX_3135EFF68D9F6D38', []); |
||
841 | $table->addIndex(['owner_id'], 'IDX_3135EFF67E3C61F9', []); |
||
842 | $table->setPrimaryKey(['id']); |
||
843 | } |
||
844 | |||
845 | /** |
||
846 | * Create orocrm_magento_newsl_subscr table |
||
847 | * |
||
848 | * @param Schema $schema |
||
849 | */ |
||
850 | protected function createOrocrmMagentoNewslSubscrTable(Schema $schema) |
||
851 | { |
||
852 | $table = $schema->createTable('orocrm_magento_newsl_subscr'); |
||
853 | $table->addColumn('id', 'integer', ['autoincrement' => true]); |
||
854 | $table->addColumn('organization_id', 'integer', ['notnull' => false]); |
||
855 | $table->addColumn('owner_id', 'integer', ['notnull' => false]); |
||
856 | $table->addColumn('customer_id', 'integer', ['notnull' => false]); |
||
857 | $table->addColumn('store_id', 'integer', ['notnull' => false]); |
||
858 | $table->addColumn('channel_id', 'integer', ['notnull' => false]); |
||
859 | $table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
||
860 | $table->addColumn('email', 'string', ['notnull' => false, 'length' => 255]); |
||
861 | $table->addColumn('change_status_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
||
862 | $table->addColumn('created_at', 'datetime', ['comment' => '(DC2Type:datetime)']); |
||
863 | $table->addColumn('updated_at', 'datetime', ['comment' => '(DC2Type:datetime)']); |
||
864 | $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
||
865 | $table->addColumn('confirm_code', 'string', ['notnull' => false, 'length' => 32]); |
||
866 | $table->setPrimaryKey(['id']); |
||
867 | |||
868 | $this->extendExtension->addEnumField( |
||
869 | $schema, |
||
870 | $table, |
||
871 | 'status', |
||
872 | 'mage_subscr_status', |
||
873 | false, |
||
874 | false, |
||
875 | [ |
||
876 | 'extend' => ['owner' => ExtendScope::OWNER_CUSTOM] |
||
877 | ] |
||
878 | ); |
||
879 | } |
||
880 | |||
881 | /** |
||
882 | * Add orocrm_magento_cart_address foreign keys. |
||
883 | * |
||
884 | * @param Schema $schema |
||
885 | */ |
||
886 | protected function addOrocrmMagentoCartAddressForeignKeys(Schema $schema) |
||
908 | |||
909 | /** |
||
910 | * Add orocrm_magento_order foreign keys. |
||
911 | * |
||
912 | * @param Schema $schema |
||
913 | */ |
||
914 | View Code Duplication | protected function addOrocrmMagentoOrderForeignKeys(Schema $schema) |
|
915 | { |
||
916 | $table = $schema->getTable('orocrm_magento_order'); |
||
917 | $table->addForeignKeyConstraint( |
||
918 | $schema->getTable('orocrm_magento_customer'), |
||
919 | ['customer_id'], |
||
920 | ['id'], |
||
921 | ['onDelete' => 'SET NULL'] |
||
922 | ); |
||
923 | $table->addForeignKeyConstraint( |
||
924 | $schema->getTable('orocrm_magento_store'), |
||
925 | ['store_id'], |
||
926 | ['id'], |
||
927 | ['onDelete' => 'SET NULL'] |
||
928 | ); |
||
929 | $table->addForeignKeyConstraint( |
||
930 | $schema->getTable('orocrm_magento_cart'), |
||
931 | ['cart_id'], |
||
932 | ['id'], |
||
933 | [] |
||
934 | ); |
||
935 | $table->addForeignKeyConstraint( |
||
936 | $schema->getTable('oro_workflow_item'), |
||
937 | ['workflow_item_id'], |
||
938 | ['id'], |
||
939 | ['onDelete' => 'SET NULL'] |
||
940 | ); |
||
941 | $table->addForeignKeyConstraint( |
||
942 | $schema->getTable('oro_workflow_step'), |
||
943 | ['workflow_step_id'], |
||
944 | ['id'], |
||
945 | ['onDelete' => 'SET NULL'] |
||
946 | ); |
||
947 | $table->addForeignKeyConstraint( |
||
948 | $schema->getTable('oro_user'), |
||
949 | ['user_owner_id'], |
||
950 | ['id'], |
||
951 | ['onDelete' => 'SET NULL'] |
||
952 | ); |
||
953 | $table->addForeignKeyConstraint( |
||
954 | $schema->getTable('oro_integration_channel'), |
||
955 | ['channel_id'], |
||
956 | ['id'], |
||
957 | ['onDelete' => 'SET NULL'] |
||
958 | ); |
||
959 | $table->addForeignKeyConstraint( |
||
960 | $schema->getTable('orocrm_channel'), |
||
961 | ['data_channel_id'], |
||
962 | ['id'], |
||
963 | ['onDelete' => 'SET NULL', 'onUpdate' => null], |
||
964 | 'FK_4D09F305BDC09B73' |
||
965 | ); |
||
966 | $table->addForeignKeyConstraint( |
||
967 | $schema->getTable('oro_organization'), |
||
968 | ['organization_id'], |
||
969 | ['id'], |
||
970 | ['onDelete' => 'SET NULL', 'onUpdate' => null], |
||
971 | 'FK_4D09F30532C8A3DE' |
||
972 | ); |
||
973 | } |
||
974 | |||
975 | /** |
||
976 | * Add orocrm_magento_order_calls foreign keys. |
||
977 | * |
||
978 | * @param Schema $schema |
||
979 | */ |
||
980 | View Code Duplication | protected function addOrocrmMagentoOrderCallsForeignKeys(Schema $schema) |
|
981 | { |
||
982 | $table = $schema->getTable('orocrm_magento_order_calls'); |
||
983 | $table->addForeignKeyConstraint( |
||
984 | $schema->getTable('orocrm_magento_order'), |
||
985 | ['order_id'], |
||
986 | ['id'], |
||
987 | ['onDelete' => 'CASCADE'] |
||
988 | ); |
||
989 | $table->addForeignKeyConstraint( |
||
990 | $schema->getTable('orocrm_call'), |
||
991 | ['call_id'], |
||
992 | ['id'], |
||
993 | ['onDelete' => 'CASCADE'] |
||
994 | ); |
||
995 | } |
||
996 | |||
997 | /** |
||
998 | * Add orocrm_magento_order_emails foreign keys. |
||
999 | * |
||
1000 | * @param Schema $schema |
||
1001 | */ |
||
1002 | View Code Duplication | protected function addOrocrmMagentoOrderEmailsForeignKeys(Schema $schema) |
|
1003 | { |
||
1004 | $table = $schema->getTable('orocrm_magento_order_emails'); |
||
1005 | $table->addForeignKeyConstraint( |
||
1006 | $schema->getTable('orocrm_magento_order'), |
||
1007 | ['order_id'], |
||
1008 | ['id'], |
||
1009 | ['onDelete' => 'CASCADE'] |
||
1010 | ); |
||
1011 | $table->addForeignKeyConstraint( |
||
1012 | $schema->getTable('oro_email'), |
||
1013 | ['email_id'], |
||
1014 | ['id'], |
||
1015 | ['onDelete' => 'CASCADE'] |
||
1016 | ); |
||
1017 | } |
||
1018 | |||
1019 | /** |
||
1020 | * Add orocrm_magento_customer_group foreign keys. |
||
1021 | * |
||
1022 | * @param Schema $schema |
||
1023 | */ |
||
1024 | View Code Duplication | protected function addOrocrmMagentoCustomerGroupForeignKeys(Schema $schema) |
|
1025 | { |
||
1026 | $table = $schema->getTable('orocrm_magento_customer_group'); |
||
1027 | $table->addForeignKeyConstraint( |
||
1028 | $schema->getTable('oro_integration_channel'), |
||
1029 | ['channel_id'], |
||
1030 | ['id'], |
||
1031 | ['onDelete' => 'SET NULL'] |
||
1032 | ); |
||
1033 | } |
||
1034 | |||
1035 | /** |
||
1036 | * Add orocrm_magento_customer foreign keys. |
||
1037 | * |
||
1038 | * @param Schema $schema |
||
1039 | */ |
||
1040 | View Code Duplication | protected function addOrocrmMagentoCustomerForeignKeys(Schema $schema) |
|
1041 | { |
||
1042 | $table = $schema->getTable('orocrm_magento_customer'); |
||
1043 | $table->addForeignKeyConstraint( |
||
1044 | $schema->getTable('orocrm_magento_website'), |
||
1045 | ['website_id'], |
||
1046 | ['id'], |
||
1047 | ['onDelete' => 'SET NULL'] |
||
1048 | ); |
||
1049 | $table->addForeignKeyConstraint( |
||
1050 | $schema->getTable('orocrm_magento_store'), |
||
1051 | ['store_id'], |
||
1052 | ['id'], |
||
1053 | ['onDelete' => 'SET NULL'] |
||
1054 | ); |
||
1055 | $table->addForeignKeyConstraint( |
||
1056 | $schema->getTable('orocrm_magento_customer_group'), |
||
1057 | ['customer_group_id'], |
||
1058 | ['id'], |
||
1059 | ['onDelete' => 'SET NULL'] |
||
1060 | ); |
||
1061 | $table->addForeignKeyConstraint( |
||
1062 | $schema->getTable('orocrm_contact'), |
||
1063 | ['contact_id'], |
||
1064 | ['id'], |
||
1065 | ['onDelete' => 'SET NULL'] |
||
1066 | ); |
||
1067 | $table->addForeignKeyConstraint( |
||
1068 | $schema->getTable('orocrm_account'), |
||
1069 | ['account_id'], |
||
1070 | ['id'], |
||
1071 | ['onDelete' => 'SET NULL'] |
||
1072 | ); |
||
1073 | $table->addForeignKeyConstraint( |
||
1074 | $schema->getTable('oro_user'), |
||
1075 | ['user_owner_id'], |
||
1076 | ['id'], |
||
1077 | ['onDelete' => 'SET NULL'] |
||
1078 | ); |
||
1079 | $table->addForeignKeyConstraint( |
||
1080 | $schema->getTable('oro_integration_channel'), |
||
1081 | ['channel_id'], |
||
1082 | ['id'], |
||
1083 | ['onDelete' => 'SET NULL'] |
||
1084 | ); |
||
1085 | $table->addForeignKeyConstraint( |
||
1086 | $schema->getTable('orocrm_channel'), |
||
1087 | ['data_channel_id'], |
||
1088 | ['id'], |
||
1089 | ['onDelete' => 'SET NULL', 'onUpdate' => null], |
||
1090 | 'FK_2A61EE7DBDC09B73' |
||
1091 | ); |
||
1092 | $table->addForeignKeyConstraint( |
||
1093 | $schema->getTable('oro_organization'), |
||
1094 | ['organization_id'], |
||
1095 | ['id'], |
||
1096 | ['onDelete' => 'SET NULL', 'onUpdate' => null], |
||
1097 | 'FK_2A61EE7D32C8A3DE' |
||
1098 | ); |
||
1099 | } |
||
1100 | |||
1101 | /** |
||
1102 | * Add orocrm_magento_cart_item foreign keys. |
||
1103 | * |
||
1104 | * @param Schema $schema |
||
1105 | */ |
||
1106 | View Code Duplication | protected function addOrocrmMagentoCartItemForeignKeys(Schema $schema) |
|
1128 | |||
1129 | /** |
||
1130 | * Add orocrm_magento_customer_addr foreign keys. |
||
1131 | * |
||
1132 | * @param Schema $schema |
||
1133 | */ |
||
1134 | protected function addOrocrmMagentoCustomerAddrForeignKeys(Schema $schema) |
||
1135 | { |
||
1136 | $table = $schema->getTable('orocrm_magento_customer_addr'); |
||
1137 | $table->addForeignKeyConstraint( |
||
1138 | $schema->getTable('orocrm_magento_customer'), |
||
1139 | ['owner_id'], |
||
1140 | ['id'], |
||
1141 | ['onDelete' => 'CASCADE'] |
||
1142 | ); |
||
1143 | $table->addForeignKeyConstraint( |
||
1144 | $schema->getTable('orocrm_contact_address'), |
||
1145 | ['related_contact_address_id'], |
||
1146 | ['id'], |
||
1147 | ['onDelete' => 'SET NULL'] |
||
1148 | ); |
||
1149 | $table->addForeignKeyConstraint( |
||
1150 | $schema->getTable('orocrm_contact_phone'), |
||
1151 | ['related_contact_phone_id'], |
||
1152 | ['id'], |
||
1153 | ['onDelete' => 'SET NULL'] |
||
1154 | ); |
||
1155 | $table->addForeignKeyConstraint( |
||
1156 | $schema->getTable('oro_dictionary_country'), |
||
1157 | ['country_code'], |
||
1158 | ['iso2_code'], |
||
1159 | [] |
||
1160 | ); |
||
1161 | $table->addForeignKeyConstraint( |
||
1162 | $schema->getTable('oro_dictionary_region'), |
||
1163 | ['region_code'], |
||
1164 | ['combined_code'], |
||
1165 | [] |
||
1166 | ); |
||
1167 | $table->addForeignKeyConstraint( |
||
1168 | $schema->getTable('oro_integration_channel'), |
||
1169 | ['channel_id'], |
||
1170 | ['id'], |
||
1171 | ['onDelete' => 'SET NULL'] |
||
1172 | ); |
||
1173 | } |
||
1174 | |||
1175 | /** |
||
1176 | * Add orocrm_magento_cust_addr_type foreign keys. |
||
1177 | * |
||
1178 | * @param Schema $schema |
||
1179 | */ |
||
1180 | View Code Duplication | protected function addOrocrmMagentoCustAddrTypeForeignKeys(Schema $schema) |
|
1181 | { |
||
1182 | $table = $schema->getTable('orocrm_magento_cust_addr_type'); |
||
1183 | $table->addForeignKeyConstraint( |
||
1184 | $schema->getTable('orocrm_magento_customer_addr'), |
||
1185 | ['customer_address_id'], |
||
1186 | ['id'], |
||
1187 | ['onDelete' => 'CASCADE'], |
||
1188 | 'FK_308A31F187EABF7' |
||
1189 | ); |
||
1190 | $table->addForeignKeyConstraint( |
||
1191 | $schema->getTable('oro_address_type'), |
||
1192 | ['type_name'], |
||
1193 | ['name'], |
||
1194 | [] |
||
1195 | ); |
||
1196 | } |
||
1197 | |||
1198 | /** |
||
1199 | * Add orocrm_magento_order_address foreign keys. |
||
1200 | * |
||
1201 | * @param Schema $schema |
||
1202 | */ |
||
1203 | protected function addOrocrmMagentoOrderAddressForeignKeys(Schema $schema) |
||
1204 | { |
||
1205 | $table = $schema->getTable('orocrm_magento_order_address'); |
||
1206 | $table->addForeignKeyConstraint( |
||
1207 | $schema->getTable('orocrm_magento_order'), |
||
1208 | ['owner_id'], |
||
1209 | ['id'], |
||
1210 | ['onDelete' => 'CASCADE'] |
||
1211 | ); |
||
1212 | $table->addForeignKeyConstraint( |
||
1213 | $schema->getTable('oro_dictionary_country'), |
||
1214 | ['country_code'], |
||
1215 | ['iso2_code'], |
||
1216 | [] |
||
1217 | ); |
||
1218 | $table->addForeignKeyConstraint( |
||
1219 | $schema->getTable('oro_dictionary_region'), |
||
1220 | ['region_code'], |
||
1221 | ['combined_code'], |
||
1222 | [] |
||
1223 | ); |
||
1224 | $table->addForeignKeyConstraint( |
||
1225 | $schema->getTable('oro_integration_channel'), |
||
1226 | ['channel_id'], |
||
1227 | ['id'], |
||
1228 | ['onDelete' => 'SET NULL'] |
||
1229 | ); |
||
1230 | } |
||
1231 | |||
1232 | /** |
||
1233 | * Add orocrm_magento_order_addr_type foreign keys. |
||
1234 | * |
||
1235 | * @param Schema $schema |
||
1236 | */ |
||
1237 | View Code Duplication | protected function addOrocrmMagentoOrderAddrTypeForeignKeys(Schema $schema) |
|
1238 | { |
||
1239 | $table = $schema->getTable('orocrm_magento_order_addr_type'); |
||
1240 | $table->addForeignKeyConstraint( |
||
1241 | $schema->getTable('orocrm_magento_order_address'), |
||
1242 | ['order_address_id'], |
||
1243 | ['id'], |
||
1244 | ['onDelete' => 'CASCADE'], |
||
1245 | 'FK_E927A18F466D5220' |
||
1246 | ); |
||
1247 | $table->addForeignKeyConstraint( |
||
1248 | $schema->getTable('oro_address_type'), |
||
1249 | ['type_name'], |
||
1250 | ['name'], |
||
1251 | [] |
||
1252 | ); |
||
1253 | } |
||
1254 | |||
1255 | /** |
||
1256 | * Add orocrm_magento_product foreign keys. |
||
1257 | * |
||
1258 | * @param Schema $schema |
||
1259 | */ |
||
1260 | View Code Duplication | protected function addOrocrmMagentoProductForeignKeys(Schema $schema) |
|
1261 | { |
||
1262 | $table = $schema->getTable('orocrm_magento_product'); |
||
1263 | $table->addForeignKeyConstraint( |
||
1264 | $schema->getTable('oro_integration_channel'), |
||
1265 | ['channel_id'], |
||
1266 | ['id'], |
||
1267 | ['onDelete' => 'SET NULL'] |
||
1268 | ); |
||
1269 | } |
||
1270 | |||
1271 | /** |
||
1272 | * Add orocrm_magento_prod_to_website foreign keys. |
||
1273 | * |
||
1274 | * @param Schema $schema |
||
1275 | */ |
||
1276 | View Code Duplication | protected function addOrocrmMagentoProdToWebsiteForeignKeys(Schema $schema) |
|
1277 | { |
||
1278 | $table = $schema->getTable('orocrm_magento_prod_to_website'); |
||
1279 | $table->addForeignKeyConstraint( |
||
1280 | $schema->getTable('orocrm_magento_product'), |
||
1281 | ['product_id'], |
||
1282 | ['id'], |
||
1283 | ['onDelete' => 'CASCADE'] |
||
1284 | ); |
||
1285 | $table->addForeignKeyConstraint( |
||
1286 | $schema->getTable('orocrm_magento_website'), |
||
1287 | ['website_id'], |
||
1288 | ['id'], |
||
1289 | ['onDelete' => 'CASCADE'] |
||
1290 | ); |
||
1291 | } |
||
1292 | |||
1293 | /** |
||
1294 | * Add orocrm_magento_website foreign keys. |
||
1295 | * |
||
1296 | * @param Schema $schema |
||
1297 | */ |
||
1298 | View Code Duplication | protected function addOrocrmMagentoWebsiteForeignKeys(Schema $schema) |
|
1299 | { |
||
1300 | $table = $schema->getTable('orocrm_magento_website'); |
||
1301 | $table->addForeignKeyConstraint( |
||
1302 | $schema->getTable('oro_integration_channel'), |
||
1303 | ['channel_id'], |
||
1304 | ['id'], |
||
1305 | ['onDelete' => 'SET NULL'] |
||
1306 | ); |
||
1307 | } |
||
1308 | |||
1309 | /** |
||
1310 | * Add orocrm_magento_cart foreign keys. |
||
1311 | * |
||
1312 | * @param Schema $schema |
||
1313 | */ |
||
1314 | protected function addOrocrmMagentoCartForeignKeys(Schema $schema) |
||
1315 | { |
||
1316 | $table = $schema->getTable('orocrm_magento_cart'); |
||
1317 | $table->addForeignKeyConstraint( |
||
1318 | $schema->getTable('orocrm_magento_customer'), |
||
1319 | ['customer_id'], |
||
1320 | ['id'], |
||
1321 | ['onDelete' => 'CASCADE'] |
||
1322 | ); |
||
1323 | $table->addForeignKeyConstraint( |
||
1324 | $schema->getTable('orocrm_magento_store'), |
||
1325 | ['store_id'], |
||
1326 | ['id'], |
||
1327 | ['onDelete' => 'SET NULL'] |
||
1328 | ); |
||
1329 | $table->addForeignKeyConstraint( |
||
1330 | $schema->getTable('orocrm_magento_cart_address'), |
||
1331 | ['shipping_address_id'], |
||
1332 | ['id'], |
||
1333 | ['onDelete' => 'SET NULL'] |
||
1334 | ); |
||
1335 | $table->addForeignKeyConstraint( |
||
1336 | $schema->getTable('orocrm_magento_cart_address'), |
||
1337 | ['billing_address_id'], |
||
1338 | ['id'], |
||
1339 | ['onDelete' => 'SET NULL'] |
||
1340 | ); |
||
1341 | $table->addForeignKeyConstraint( |
||
1342 | $schema->getTable('orocrm_magento_cart_status'), |
||
1343 | ['status_name'], |
||
1344 | ['name'], |
||
1345 | ['onDelete' => 'SET NULL'] |
||
1346 | ); |
||
1347 | $table->addForeignKeyConstraint( |
||
1348 | $schema->getTable('orocrm_sales_opportunity'), |
||
1349 | ['opportunity_id'], |
||
1350 | ['id'], |
||
1351 | ['onDelete' => 'SET NULL'] |
||
1352 | ); |
||
1353 | $table->addForeignKeyConstraint( |
||
1354 | $schema->getTable('oro_workflow_item'), |
||
1355 | ['workflow_item_id'], |
||
1356 | ['id'], |
||
1357 | ['onDelete' => 'SET NULL'] |
||
1358 | ); |
||
1359 | $table->addForeignKeyConstraint( |
||
1360 | $schema->getTable('oro_workflow_step'), |
||
1361 | ['workflow_step_id'], |
||
1362 | ['id'], |
||
1363 | ['onDelete' => 'SET NULL'] |
||
1364 | ); |
||
1365 | $table->addForeignKeyConstraint( |
||
1366 | $schema->getTable('oro_user'), |
||
1367 | ['user_owner_id'], |
||
1368 | ['id'], |
||
1369 | ['onDelete' => 'SET NULL'] |
||
1370 | ); |
||
1371 | $table->addForeignKeyConstraint( |
||
1372 | $schema->getTable('oro_integration_channel'), |
||
1373 | ['channel_id'], |
||
1374 | ['id'], |
||
1375 | ['onDelete' => 'SET NULL'] |
||
1376 | ); |
||
1377 | $table->addForeignKeyConstraint( |
||
1378 | $schema->getTable('orocrm_channel'), |
||
1379 | ['data_channel_id'], |
||
1380 | ['id'], |
||
1381 | ['onDelete' => 'SET NULL', 'onUpdate' => null], |
||
1382 | 'FK_96661A80BDC09B73' |
||
1383 | ); |
||
1384 | $table->addForeignKeyConstraint( |
||
1385 | $schema->getTable('oro_organization'), |
||
1386 | ['organization_id'], |
||
1387 | ['id'], |
||
1388 | ['onDelete' => 'SET NULL', 'onUpdate' => null], |
||
1389 | 'FK_96661A8032C8A3DE' |
||
1390 | ); |
||
1391 | } |
||
1392 | |||
1393 | /** |
||
1394 | * Add orocrm_magento_cart_calls foreign keys. |
||
1395 | * |
||
1396 | * @param Schema $schema |
||
1397 | */ |
||
1398 | View Code Duplication | protected function addOrocrmMagentoCartCallsForeignKeys(Schema $schema) |
|
1399 | { |
||
1400 | $table = $schema->getTable('orocrm_magento_cart_calls'); |
||
1401 | $table->addForeignKeyConstraint( |
||
1402 | $schema->getTable('orocrm_magento_cart'), |
||
1403 | ['cart_id'], |
||
1404 | ['id'], |
||
1405 | ['onDelete' => 'CASCADE'] |
||
1406 | ); |
||
1407 | $table->addForeignKeyConstraint( |
||
1408 | $schema->getTable('orocrm_call'), |
||
1409 | ['call_id'], |
||
1410 | ['id'], |
||
1411 | ['onDelete' => 'CASCADE'] |
||
1412 | ); |
||
1413 | } |
||
1414 | |||
1415 | /** |
||
1416 | * Add orocrm_magento_cart_emails foreign keys. |
||
1417 | * |
||
1418 | * @param Schema $schema |
||
1419 | */ |
||
1420 | View Code Duplication | protected function addOrocrmMagentoCartEmailsForeignKeys(Schema $schema) |
|
1421 | { |
||
1422 | $table = $schema->getTable('orocrm_magento_cart_emails'); |
||
1423 | $table->addForeignKeyConstraint( |
||
1424 | $schema->getTable('orocrm_magento_cart'), |
||
1425 | ['cart_id'], |
||
1426 | ['id'], |
||
1427 | ['onDelete' => 'CASCADE'] |
||
1428 | ); |
||
1429 | $table->addForeignKeyConstraint( |
||
1430 | $schema->getTable('oro_email'), |
||
1431 | ['email_id'], |
||
1432 | ['id'], |
||
1433 | ['onDelete' => 'CASCADE'] |
||
1434 | ); |
||
1435 | } |
||
1436 | |||
1437 | /** |
||
1438 | * Add orocrm_magento_store foreign keys. |
||
1439 | * |
||
1440 | * @param Schema $schema |
||
1441 | */ |
||
1442 | View Code Duplication | protected function addOrocrmMagentoStoreForeignKeys(Schema $schema) |
|
1443 | { |
||
1444 | $table = $schema->getTable('orocrm_magento_store'); |
||
1445 | $table->addForeignKeyConstraint( |
||
1446 | $schema->getTable('orocrm_magento_website'), |
||
1447 | ['website_id'], |
||
1448 | ['id'], |
||
1449 | ['onDelete' => 'cascade'] |
||
1450 | ); |
||
1451 | $table->addForeignKeyConstraint( |
||
1452 | $schema->getTable('oro_integration_channel'), |
||
1453 | ['channel_id'], |
||
1454 | ['id'], |
||
1455 | ['onDelete' => 'SET NULL'] |
||
1456 | ); |
||
1457 | } |
||
1458 | |||
1459 | /** |
||
1460 | * Add orocrm_magento_order_items foreign keys. |
||
1461 | * |
||
1462 | * @param Schema $schema |
||
1463 | */ |
||
1464 | View Code Duplication | protected function addOrocrmMagentoOrderItemsForeignKeys(Schema $schema) |
|
1486 | |||
1487 | /** |
||
1488 | * Add orocrm_magento_newsl_subscr foreign keys. |
||
1489 | * |
||
1490 | * @param Schema $schema |
||
1491 | */ |
||
1492 | View Code Duplication | protected function addOrocrmMagentoNewslSubscrForeignKeys(Schema $schema) |
|
1493 | { |
||
1494 | $table = $schema->getTable('orocrm_magento_newsl_subscr'); |
||
1495 | $table->addForeignKeyConstraint( |
||
1496 | $schema->getTable('oro_organization'), |
||
1497 | ['organization_id'], |
||
1498 | ['id'], |
||
1499 | ['onUpdate' => null, 'onDelete' => 'SET NULL'] |
||
1500 | ); |
||
1501 | $table->addForeignKeyConstraint( |
||
1502 | $schema->getTable('oro_user'), |
||
1503 | ['owner_id'], |
||
1504 | ['id'], |
||
1505 | ['onUpdate' => null, 'onDelete' => 'SET NULL'] |
||
1506 | ); |
||
1507 | $table->addForeignKeyConstraint( |
||
1508 | $schema->getTable('orocrm_magento_customer'), |
||
1509 | ['customer_id'], |
||
1510 | ['id'], |
||
1511 | ['onUpdate' => null, 'onDelete' => 'SET NULL'] |
||
1512 | ); |
||
1513 | $table->addForeignKeyConstraint( |
||
1514 | $schema->getTable('orocrm_magento_store'), |
||
1515 | ['store_id'], |
||
1516 | ['id'], |
||
1517 | ['onUpdate' => null, 'onDelete' => 'SET NULL'] |
||
1518 | ); |
||
1519 | $table->addForeignKeyConstraint( |
||
1520 | $schema->getTable('oro_integration_channel'), |
||
1521 | ['channel_id'], |
||
1522 | ['id'], |
||
1523 | ['onUpdate' => null, 'onDelete' => 'SET NULL'] |
||
1524 | ); |
||
1525 | $table->addForeignKeyConstraint( |
||
1532 | |||
1533 | /** |
||
1534 | * Enable activities |
||
1535 | * |
||
1536 | * @param Schema $schema |
||
1537 | */ |
||
1538 | protected function addActivityAssociations(Schema $schema) |
||
1548 | |||
1549 | /** |
||
1550 | * @param Schema $schema |
||
1551 | */ |
||
1552 | protected function addIdentifierEventAssociations(Schema $schema) |
||
1560 | } |
||
1561 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.