-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOC2200toOC3039.sql
655 lines (621 loc) · 13.3 KB
/
OC2200toOC3039.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
-- BEGIN TRANSACTION
insert into [opencart3_db].api
select *
from [opencart22_db].api a1
where not exists (
select 1
from [opencart3_db].api a2
where a1.api_id = a2.api_id);
insert into [opencart3_db].api_ip
select *
from [opencart22_db].api_ip a1
where not exists (
select 1
from [opencart3_db].api_ip a2
where a1.api_ip_id = a2.api_ip_id);
insert into [opencart3_db].api_session (
api_session_id,
api_id,
session_id,
ip,
date_added,
date_modified)
select
api_session_id,
api_id,
session_id,
ip,
date_added,
date_modified
from [opencart22_db].api_session a1
where not exists (select 1 from [opencart3_db].api_session a2 where a1.api_session_id = a2.api_session_id);
insert into [opencart3_db].category (
category_id,
image,
parent_id,
top,
`column`,
sort_order,
status,
date_added,
date_modified)
select
category_id,
image,
parent_id,
top,
`column`,
sort_order,
status,
date_added,
date_modified
from [opencart22_db].category c1
where not exists (
select 1
from [opencart3_db].category c2
where c1.category_id = c2.category_id);
insert into [opencart3_db].category_description
select *
from [opencart22_db].category_description cd1
where not exists (
select 1
from [opencart3_db].category_description cd2
where cd2.category_id = cd1.category_id);
-- DELETE FROM [opencart3_db].category_path
insert into [opencart3_db].category_path
select *
from [opencart22_db].category_path cp1
where not exists
(
select 1
from [opencart3_db].category_path cp2
where cp1.category_id = cp2.category_id
and cp1.path_id = cp2.path_id);
insert into [opencart3_db].customer (
customer_id,
customer_group_id,
store_id,
language_id,
firstname,
lastname,
email,
telephone,
fax,
password,
salt,
custom_field,
newsletter,
ip,
status,
safe,
token,
code,
date_added)
select customer_id
,customer_group_id
,store_id
,language_id
,firstname
,lastname
,email
,telephone
,fax
,password
,salt
,custom_field
,newsletter
,ip
,status
,safe
,token
,code
,date_added
from [opencart22_db].customer c1
where not exists (
select 1
from [opencart3_db].customer c2
where c1.customer_id = c2.customer_id
and c1.store_id = c2.store_id);
insert into [opencart3_db].product (
`product_id`,
-- `master_id`,
`model`,
`sku`,
`upc`,
`ean`,
`jan`,
`isbn`,
`mpn`,
`location`,
-- `variant`,
-- `override`,
`quantity`,
`stock_status_id`,
`image`,
`manufacturer_id`,
`shipping`,
`price`,
`points`,
`tax_class_id`,
`date_available`,
`weight`,
`weight_class_id`,
`length`,
`width`,
`height`,
`length_class_id`,
`subtract`,
`minimum`,
-- `rating`,
`sort_order`,
`status`,
`date_added`,
`date_modified`)
select
`product_id`,
-- 0, -- master_id
`model`,
`sku`,
`upc`,
`ean`,
`jan`,
`isbn`,
`mpn`,
`location`,
-- '', -- `variant`
-- '', -- `override`,
`quantity`,
`stock_status_id`,
`image`,
`manufacturer_id`,
`shipping`,
`price`,
`points`,
`tax_class_id`,
`date_available`,
`weight`,
`weight_class_id`,
`length`,
`width`,
`height`,
`length_class_id`,
`subtract`,
`minimum`,
-- 0,
`sort_order`,
`status`,
`date_added`,
`date_modified`
from `belleson_cart`.`product` p1
where not exists (
select 1
from [opencart3_db].product p2
where p1.product_id = p2.product_id);
insert into [opencart3_db].product_to_category
select *
from [opencart22_db].product_to_category pc1
where not exists
(select 1 from [opencart3_db].product_to_category pc2
where pc1.product_id = pc2.product_id
and pc1.category_id = pc2.category_id);
insert into [opencart3_db].product_to_store
select *
from [opencart22_db].product_to_store ps1
where not exists (
select 1
from [opencart3_db].product_to_store ps2
where ps1.product_id = ps2.product_id
and ps1.store_id = ps2.store_id);
insert into [opencart3_db].product_attribute
select *
from [opencart22_db].product_attribute pa1
where not exists (
select 1
from [opencart3_db].product_attribute pa2
where pa1.product_id = pa2.product_id
and pa1.attribute_id = pa2.attribute_id);
insert into [opencart3_db].product_option
select *
from [opencart22_db].product_option po
where not exists (
select 1
from [opencart3_db].product_option po2
where po.option_id = po2.option_id
and po.product_id = po2.product_id);
insert into [opencart3_db].product_option_value
select *
from [opencart22_db].product_option_value pov
where not exists (
select 1
from [opencart3_db].product_option_value pov2
where pov.product_option_id = pov2.product_option_id
and pov.option_id = pov2.option_id
and pov.product_id = pov2.product_id);
insert into [opencart3_db].product_related
select *
from [opencart22_db].product_related pr1
where not exists (
select 1 from [opencart3_db].product_related pr2
where pr1.product_id = pr2.product_id
and pr1.related_id = pr2.related_id);
insert into [opencart3_db].product_attribute
select *
from [opencart22_db].product_attribute pa1
where not exists (
select 1
from [opencart3_db].product_attribute pa2
where pa1.product_id = pa2.product_id
and pa1.attribute_id = pa2.attribute_id);
insert into [opencart3_db].product_discount (
product_discount_id
,product_id
,customer_group_id
,quantity
,priority
,price
,date_start
,date_end)
select product_discount_id
,product_id
,customer_group_id
,quantity
,priority
,price
,date_start
,date_end
from [opencart22_db].product_discount pd1
where not exists (
select 1
from [opencart3_db].product_discount pd2
where pd1.product_id = pd2.product_id
and pd1.customer_group_id = pd2.customer_group_id);
-- DID NOT USE THIS INSERT, WILL DO IT MANUALLY
-- insert into [opencart3_db].product_image
-- select *
-- from [opencart22_db].product_image pi1
-- where not exists (
-- select 1
-- from [opencart3_db].product_image pi2
-- where pi1.product_image_id = pi2.product_image_id
-- and pi1.product_id = pi2.product_id);
insert into [opencart3_db].product_description (
product_id
,language_id
,name
,description
,tag
,meta_title
,meta_description
,meta_keyword)
select product_id
,language_id
,name
,description
,tag
,meta_title
,meta_description
,meta_keyword
from [opencart22_db].product_description pd1
where not exists (
select 1
from [opencart3_db].product_description pd2
where pd1.product_id = pd2.product_id);
insert into [opencart3_db].`address` (
`address_id`
,`customer_id`
,`firstname`
,`lastname`
,`company`
,`address_1`
,`address_2`
,`city`
,`postcode`
,`country_id`
,`zone_id`
,`custom_field`
-- ,`default`
)
select
`address_id`
,`customer_id`
,`firstname`
,`lastname`
,`company`
,`address_1`
,`address_2`
,`city`
,`postcode`
,`country_id`
,`zone_id`
,`custom_field`
-- ,0 -- `default`
from [opencart22_db].address a1
where not exists (
select 1
from [opencart3_db].address a2
where a1.address_id = a2.address_id
-- and a1.customer_id = a2.customer_id
);
insert into [opencart3_db].cart (
cart_id
,api_id
,customer_id
,session_id
,product_id
, recurring_id
-- ,subscription_plan_id
,`option`
,quantity
-- ,override
-- ,price
,date_added)
select cart_id
,1 -- api_id
,customer_id
,session_id
,product_id
, -1
-- ,1 -- subscription_plan_id
,`option`
,quantity
-- ,override
-- ,price
,date_added
from [opencart22_db].cart c1
where not exists (
select 1 from [opencart3_db].cart c2
where c1.cart_id = c2.cart_id
-- and c1.api_id = c2.api_id
and c1.customer_id = c2.customer_id);
insert into [opencart3_db].`order` (
`order_id`
-- ,`subscription_id`
,`invoice_no`
,`invoice_prefix`
-- ,`transaction_id`
,`store_id`
,`store_name`
,`store_url`
,`customer_id`
,`customer_group_id`
,`firstname`
,`lastname`
,`email`
,`telephone`
,fax
,`custom_field`
-- ,`payment_address_id`
,`payment_firstname`
,`payment_lastname`
,`payment_company`
,`payment_address_1`
,`payment_address_2`
,`payment_city`
,`payment_postcode`
,`payment_country`
,`payment_country_id`
,`payment_zone`
,`payment_zone_id`
,`payment_address_format`
,`payment_custom_field`
,`payment_method`
,`payment_code`
-- ,`shipping_address_id`
,`shipping_firstname`
,`shipping_lastname`
,`shipping_company`
,`shipping_address_1`
,`shipping_address_2`
,`shipping_city`
,`shipping_postcode`
,`shipping_country`
,`shipping_country_id`
,`shipping_zone`
,`shipping_zone_id`
,`shipping_address_format`
,`shipping_custom_field`
,`shipping_method`
,`shipping_code`
,`comment`
,`total`
,`order_status_id`
,`affiliate_id`
,`commission`
,`marketing_id`
,`tracking`
,`language_id`
-- ,`language_code`
,`currency_id`
,`currency_code`
,`currency_value`
,`ip`
,`forwarded_ip`
,`user_agent`
,`accept_language`
,`date_added`
,`date_modified`)
select
`order_id`
-- , -1 -- subscription_id
,`invoice_no`
,`invoice_prefix`
-- , -1 -- transaction_id
,`store_id`
,`store_name`
,`store_url`
,`customer_id`
,`customer_group_id`
,`firstname`
,`lastname`
,`email`
,`telephone`
,`fax`
,`custom_field`
-- , -1 -- payment_address_id
,`payment_firstname`
,`payment_lastname`
,`payment_company`
,`payment_address_1`
,`payment_address_2`
,`payment_city`
,`payment_postcode`
,`payment_country`
,`payment_country_id`
,`payment_zone`
,`payment_zone_id`
,`payment_address_format`
,`payment_custom_field`
,`payment_method`
,`payment_code`
-- , -1 -- shipping_address_id
,`shipping_firstname`
,`shipping_lastname`
,`shipping_company`
,`shipping_address_1`
,`shipping_address_2`
,`shipping_city`
,`shipping_postcode`
,`shipping_country`
,`shipping_country_id`
,`shipping_zone`
,`shipping_zone_id`
,`shipping_address_format`
,`shipping_custom_field`
,`shipping_method`
,`shipping_code`
,`comment`
,`total`
,`order_status_id`
,`affiliate_id`
,`commission`
,`marketing_id`
,`tracking`
,`language_id`
-- , -1 -- language_code
,`currency_id`
,`currency_code`
,`currency_value`
,`ip`
,`forwarded_ip`
,`user_agent`
,`accept_language`
,`date_added`
,`date_modified`
from [opencart22_db].`order` o1
where not exists (
select 1 from [opencart3_db].`order` o2
where o1.order_id = o2.order_id);
insert into [opencart3_db].`order_product` (order_product_id
,order_id
,product_id
-- ,master_id
,`name`
,model
,quantity
,price
,total
,tax
,reward)
select order_product_id
,order_id
,product_id
-- ,-1
,`name`
,model
,quantity
,price
,total
,tax
,reward
from [opencart22_db].`order_product` op1
where not exists (
select 1
from [opencart3_db].order_product op2
where op1.order_product_id = op2.order_product_id
and op1.order_id = op2.order_id
and op1.product_id = op2.product_id
);
insert into [opencart3_db].order_status
select * from [opencart22_db].order_status os1
where not exists (
select 1
from [opencart3_db].order_status os2
where os1.order_status_id = os2.order_status_id);
insert into [opencart3_db].order_history
select * from [opencart22_db].order_history oh1
where not exists (
select 1
from [opencart3_db].order_history oh2
where oh1.order_id = oh2.order_id
and oh1.order_status_id = oh2.order_status_id);
insert into [opencart3_db].order_option
select * from [opencart22_db].order_option oo1
where not exists (
select 1
from [opencart3_db].order_option oo2
where oo1.order_id = oo2.order_id
and oo1.order_product_id = oo2.order_product_id
and oo1.product_option_id = oo2.product_option_id
and oo1.product_option_value_id = oo2.product_option_value_id);
insert into [opencart3_db].order_total (order_total_id
,order_id
-- ,extension
,code
,title
,value
,sort_order)
select order_total_id
,order_id
-- ,''
,code
,title
,value
,sort_order
from [opencart22_db].order_total ot1
where not exists (
select 1
from [opencart3_db].order_total ot2
where ot1.order_total_id = ot2.order_total_id
and ot1.order_id = ot2.order_id);
insert into [opencart3_db].`return`
select * from [opencart22_db].`return` r1
where not exists (
select 1
from [opencart3_db].`return` r2
where r1.return_id = r2.return_id
and r1.order_id = r2.order_id
and r1.product_id = r2.product_id
and r1.customer_id = r2.customer_id);
insert into [opencart3_db].return_action
select * from [opencart22_db].return_action ra1
where not exists (
select 1
from [opencart3_db].return_action ra2
where ra1.return_action_id = ra2.return_action_id);
insert into [opencart3_db].return_history
select * from [opencart22_db].return_history rh1
where not exists (
select 1
from [opencart3_db].return_history rh2
where rh1.return_history_id = rh2.return_history_id
and rh1.return_id = rh2.return_id
and rh1.return_status_id = rh2.return_status_id);
insert into [opencart3_db].`return_reason`
select * from [opencart22_db].`return_reason` rr1
where not exists (
select 1
from [opencart3_db].return_reason rr2
where rr1.return_reason_id = rr2.return_reason_id);
insert into [opencart3_db].`return_status`
select * from [opencart22_db].`return_status` rs1
where not exists (
select 1
from [opencart3_db].return_status rs2
where rs1.return_status_id = rs2.return_status_id);
insert into [opencart3_db].`zone`
select * from [opencart22_db].`zone` z1
where not exists (
select *
from [opencart3_db].`zone` z2
where z1.zone_id = z2.zone_id
and z1.country_id = z2.country_id);