6.x-importer.sql 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. ## @version 7.4
  2. ## DISABLE FOREIGN KEY CHECKS
  3. SET foreign_key_checks = 0;
  4. SET @default_currency = (SELECT
  5. `currency`
  6. FROM `{%OLD_PREFIX%}gen_setts`
  7. LIMIT 1);
  8. ## USERS - [ OK ]
  9. # ================
  10. # COMMENTS
  11. # ================
  12. # last_login datetime - CANNOT TRANSFER AS THERE IS NOTHING SPECIFIC TO TRANSFER
  13. # global_settings text - WILL NOT TRANSFER
  14. # postage_settings = USE DEFAULT DATA [ OK ]
  15. # UPDATE THE IDS OF CURRENT USERS TO BE > THE GREATEST ID FROM THE OLD USERS TABLE
  16. DELETE FROM `{%NEW_PREFIX%}users`
  17. WHERE role != 'Admin';
  18. UPDATE `{%NEW_PREFIX%}users`
  19. SET `{%NEW_PREFIX%}users`.`id` = (
  20. SELECT
  21. max(`{%OLD_PREFIX%}users`.`user_id`) + 100
  22. FROM `{%OLD_PREFIX%}users`
  23. );
  24. INSERT INTO `{%NEW_PREFIX%}users`
  25. (`id`, `email`, `username`, `password`, `created_at`, `salt`, `birthdate`, `newsletter_subscription`,
  26. `active`, `approved`, `mail_activated`, `payment_status`, `listing_approval`,
  27. `user_verified`, `user_verified_last_payment`, `user_verified_next_payment`, `business_account`,
  28. `company_name`, `bank_details`, `account_mode`, `items_sold`, `items_bought`,
  29. `balance`, `max_debit`, `preferred_seller`, `preferred_seller_expiration`, `is_seller`,
  30. `store_active`, `store_subscription_id`, `store_name`, `store_last_payment`, `store_next_payment`, `store_settings`)
  31. SELECT
  32. `user_id`,
  33. `email`,
  34. `username`,
  35. `password`,
  36. FROM_UNIXTIME(`reg_date`),
  37. `salt`,
  38. IF(`birthdate` = '', MAKEDATE(`birthdate_year`, 1), `birthdate`),
  39. `newsletter`,
  40. `active`,
  41. `approved`,
  42. `mail_activated`,
  43. IF(`payment_status` = 'confirmed', 'confirmed', 'failed'),
  44. `auction_approval`,
  45. `seller_verified`,
  46. IF(`seller_verif_last_payment` > 0, FROM_UNIXTIME(`seller_verif_last_payment`), NULL),
  47. IF(`seller_verif_next_payment` > 0, FROM_UNIXTIME(`seller_verif_next_payment`), NULL),
  48. `tax_account_type`,
  49. `tax_company_name`,
  50. `default_bank_details`,
  51. IF(`payment_mode` = '1', 'live', 'account'),
  52. `items_sold`,
  53. `items_bought`,
  54. `balance`,
  55. `max_credit`,
  56. `preferred_seller`,
  57. IF(`preferred_seller_exp_date` > 0, FROM_UNIXTIME(`preferred_seller_exp_date`), NULL),
  58. `is_seller`,
  59. `shop_active`,
  60. IF(`shop_account_id` > 0, `shop_account_id`, NULL),
  61. `shop_name`,
  62. IF(`shop_last_payment` > 0, FROM_UNIXTIME(`shop_last_payment`), NULL),
  63. IF(`shop_next_payment` > 0, FROM_UNIXTIME(`shop_next_payment`), NULL),
  64. IF(`shop_name` != '', CONCAT(
  65. 'a:6:{',
  66. 's:17:"store_description";s:', LENGTH(`shop_mainpage`), ':"', `shop_mainpage`, '";',
  67. 's:22:"store_meta_description";s:', LENGTH(`shop_metatags`), ':"', `shop_metatags`, '";',
  68. 's:15:"store_logo_path";s:', LENGTH(`shop_logo_path`), ':"', `shop_logo_path`, '";',
  69. 's:11:"store_about";s:', LENGTH(`shop_about`), ':"', `shop_about`, '";',
  70. 's:26:"store_shipping_information";s:', LENGTH(`shop_shipping_info`), ':"', `shop_shipping_info`, '";',
  71. 's:22:"store_company_policies";s:', LENGTH(`shop_company_policies`), ':"', `shop_company_policies`, '";',
  72. '}'),
  73. '')
  74. FROM `{%OLD_PREFIX%}users`;
  75. ## USERS ADDRESS BOOK - [ OK ]
  76. TRUNCATE TABLE `{%NEW_PREFIX%}users_address_book`;
  77. INSERT INTO `{%NEW_PREFIX%}users_address_book`
  78. (`user_id`, `address`, `is_primary`)
  79. SELECT
  80. `user_id`,
  81. CONCAT(
  82. 'a:7:{',
  83. 's:4:"name";',
  84. 'a:2:{',
  85. 's:5:"first";s:', LENGTH(`first_name`), ':"', `first_name`, '";',
  86. 's:4:"last";s:', LENGTH(`last_name`), ':"', `last_name`, '";',
  87. '}',
  88. 's:7:"address";s:', LENGTH(`address`), ':"', CONVERT(`address` USING utf8), '";',
  89. 's:4:"city";s:', LENGTH(`city`), ':"', `city`, '";',
  90. 's:8:"zip_code";s:', LENGTH(`zip_code`), ':"', `zip_code`, '";',
  91. 's:7:"country";s:', LENGTH(`country`), ':"', `country`, '";',
  92. 's:5:"state";s:', LENGTH(`state`), ':"', `state`, '";',
  93. 's:5:"phone";s:', LENGTH(`phone`), ':"', `phone`, '";',
  94. '}'),
  95. '1'
  96. FROM `{%OLD_PREFIX%}users`;
  97. # SET DEFAULT POSTAGE SETTINGS FOR ALL USERS
  98. UPDATE `{%NEW_PREFIX%}users`
  99. SET
  100. `postage_settings` = 'a:3:{s:18:"shipping_locations";s:8:"domestic";s:12:"postage_type";s:4:"item";s:12:"free_postage";i:0;}';
  101. ## PAYMENT GATEWAYS TABLE AND ADMIN / USERS SETTINGS
  102. UPDATE `{%NEW_PREFIX%}payment_gateways`
  103. SET `id` = `id` + 10000;
  104. SET @paypalId = (SELECT
  105. `pg_id`
  106. FROM `{%OLD_PREFIX%}payment_gateways`
  107. WHERE `name` = 'PayPal'
  108. LIMIT 1);
  109. SET @worldpayId = (SELECT
  110. `pg_id`
  111. FROM `{%OLD_PREFIX%}payment_gateways`
  112. WHERE `name` = 'Worldpay'
  113. LIMIT 1);
  114. SET @twoCheckoutId = (SELECT
  115. `pg_id`
  116. FROM `{%OLD_PREFIX%}payment_gateways`
  117. WHERE `name` = '2Checkout'
  118. LIMIT 1);
  119. SET @protxId = (SELECT
  120. `pg_id`
  121. FROM `{%OLD_PREFIX%}payment_gateways`
  122. WHERE `name` = 'Protx'
  123. LIMIT 1);
  124. SET @nochexId = (SELECT
  125. `pg_id`
  126. FROM `{%OLD_PREFIX%}payment_gateways`
  127. WHERE `name` = 'Nochex'
  128. LIMIT 1);
  129. SET @authNetId = (SELECT
  130. `pg_id`
  131. FROM `{%OLD_PREFIX%}payment_gateways`
  132. WHERE `name` = 'Authorize.net'
  133. LIMIT 1);
  134. SET @moneybookersId = (SELECT
  135. `pg_id`
  136. FROM `{%OLD_PREFIX%}payment_gateways`
  137. WHERE `name` = 'Moneybookers'
  138. LIMIT 1);
  139. SET @paymateId = (SELECT
  140. `pg_id`
  141. FROM `{%OLD_PREFIX%}payment_gateways`
  142. WHERE `name` = 'Paymate'
  143. LIMIT 1);
  144. SET @amazonId = (SELECT
  145. `pg_id`
  146. FROM `{%OLD_PREFIX%}payment_gateways`
  147. WHERE `name` = 'Amazon'
  148. LIMIT 1);
  149. # site admin payment gateways details - TO BE INSERTED MANUALLY
  150. # users payment gateways details - setting by setting
  151. TRUNCATE TABLE `{%NEW_PREFIX%}payment_gateways_settings`;
  152. # paypal email address
  153. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  154. (`name`, `value`, `gateway_id`, `user_id`)
  155. SELECT
  156. 'business',
  157. `pg_paypal_email`,
  158. @paypalId,
  159. `user_id`
  160. FROM `{%OLD_PREFIX%}users`
  161. WHERE `pg_paypal_email` != '';
  162. # worldpay id
  163. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  164. (`name`, `value`, `gateway_id`, `user_id`)
  165. SELECT
  166. 'instId',
  167. `pg_worldpay_id`,
  168. @worldpayId,
  169. `user_id`
  170. FROM `{%OLD_PREFIX%}users`
  171. WHERE `pg_worldpay_id` != '';
  172. # 2checkout id
  173. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  174. (`name`, `value`, `gateway_id`, `user_id`)
  175. SELECT
  176. 'sid',
  177. `pg_checkout_id`,
  178. @twoCheckoutId,
  179. `user_id`
  180. FROM `{%OLD_PREFIX%}users`
  181. WHERE `pg_checkout_id` != '';
  182. # sagepay (protx) username - Vendor
  183. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  184. (`name`, `value`, `gateway_id`, `user_id`)
  185. SELECT
  186. 'Vendor',
  187. `pg_protx_username`,
  188. @protxId,
  189. `user_id`
  190. FROM `{%OLD_PREFIX%}users`
  191. WHERE `pg_protx_username` != '';
  192. # sagepay (protx) password - Password
  193. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  194. (`name`, `value`, `gateway_id`, `user_id`)
  195. SELECT
  196. 'Password',
  197. `pg_protx_password`,
  198. @protxId,
  199. `user_id`
  200. FROM `{%OLD_PREFIX%}users`
  201. WHERE `pg_protx_password` != '';
  202. # nochex merchant id - merchant_id
  203. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  204. (`name`, `value`, `gateway_id`, `user_id`)
  205. SELECT
  206. 'merchant_id',
  207. `pg_nochex_email`,
  208. @nochexId,
  209. `user_id`
  210. FROM `{%OLD_PREFIX%}users`
  211. WHERE `pg_nochex_email` != '';
  212. # authorize.net id - x_login
  213. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  214. (`name`, `value`, `gateway_id`, `user_id`)
  215. SELECT
  216. 'x_login',
  217. `pg_authnet_username`,
  218. @authNetId,
  219. `user_id`
  220. FROM `{%OLD_PREFIX%}users`
  221. WHERE `pg_authnet_username` != '';
  222. # authorize.net key - authnet_transaction_key
  223. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  224. (`name`, `value`, `gateway_id`, `user_id`)
  225. SELECT
  226. 'authnet_transaction_key',
  227. `pg_authnet_password`,
  228. @authNetId,
  229. `user_id`
  230. FROM `{%OLD_PREFIX%}users`
  231. WHERE `pg_authnet_password` != '';
  232. # skrill (moneybookers) email - pay_to_email
  233. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  234. (`name`, `value`, `gateway_id`, `user_id`)
  235. SELECT
  236. 'pay_to_email',
  237. `pg_mb_email`,
  238. @moneybookersId,
  239. `user_id`
  240. FROM `{%OLD_PREFIX%}users`
  241. WHERE `pg_mb_email` != '';
  242. # paymate id - mid
  243. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  244. (`name`, `value`, `gateway_id`, `user_id`)
  245. SELECT
  246. 'mid',
  247. `pg_paymate_merchant_id`,
  248. @paymateId,
  249. `user_id`
  250. FROM `{%OLD_PREFIX%}users`
  251. WHERE `pg_paymate_merchant_id` != '';
  252. # amazon access key - aws_access_key_id
  253. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  254. (`name`, `value`, `gateway_id`, `user_id`)
  255. SELECT
  256. 'aws_access_key_id',
  257. `pg_amazon_access_key`,
  258. @amazonId,
  259. `user_id`
  260. FROM `{%OLD_PREFIX%}users`
  261. WHERE `pg_amazon_access_key` != '';
  262. # amazon secret key - aws_secret_key_id
  263. INSERT INTO `{%NEW_PREFIX%}payment_gateways_settings`
  264. (`name`, `value`, `gateway_id`, `user_id`)
  265. SELECT
  266. 'aws_secret_key_id',
  267. `pg_amazon_secret_key`,
  268. @amazonId,
  269. `user_id`
  270. FROM `{%OLD_PREFIX%}users`
  271. WHERE `pg_amazon_secret_key` != '';
  272. ## CATEGORIES TABLE - [ OK ]
  273. TRUNCATE TABLE `{%NEW_PREFIX%}categories`;
  274. INSERT INTO `{%NEW_PREFIX%}categories`
  275. (`id`, `name`, `parent_id`, `order_id`, `user_id`, `custom_fees`, `enable_auctions`, `enable_wanted`, `meta_description`)
  276. SELECT
  277. `category_id`,
  278. `name`,
  279. IF(`parent_id` > 0, `parent_id`, NULL),
  280. `order_id`,
  281. IF(`user_id` > 0, `user_id`, NULL),
  282. `custom_fees`,
  283. IF(`parent_id` > 0, '1', `enable_auctions`),
  284. IF(`parent_id` > 0, '1', `enable_wanted`),
  285. `meta_description`
  286. FROM `{%OLD_PREFIX%}categories`
  287. WHERE `{%OLD_PREFIX%}categories`.`user_id` = '0';
  288. ## LOCATIONS/COUNTRIES TABLE - [ OK ]
  289. TRUNCATE TABLE `{%NEW_PREFIX%}locations`;
  290. INSERT INTO `{%NEW_PREFIX%}locations`
  291. (`id`, `name`, `iso_code`, `parent_id`, `order_id`)
  292. SELECT
  293. `id`,
  294. `name`,
  295. `country_iso_code`,
  296. IF(`parent_id` > 0, `parent_id`, NULL),
  297. `country_order`
  298. FROM `{%OLD_PREFIX%}countries`;
  299. ## CURRENCIES TABLE - [ OK ]
  300. TRUNCATE TABLE `{%NEW_PREFIX%}currencies`;
  301. INSERT INTO `{%NEW_PREFIX%}currencies`
  302. (`id`, `iso_code`, `symbol`, `description`, `conversion_rate`)
  303. SELECT
  304. `id`,
  305. `symbol`,
  306. `currency_symbol`,
  307. `caption`,
  308. `convert_rate`
  309. FROM `{%OLD_PREFIX%}currencies`;
  310. ## AUCTIONS
  311. TRUNCATE TABLE `{%NEW_PREFIX%}listings`;
  312. INSERT INTO `{%NEW_PREFIX%}listings`
  313. (`id`, `listing_type`, `name`, `description`, `user_id`, `list_in`, `category_id`, `addl_category_id`, `currency`,
  314. `quantity`, `start_price`, `reserve_price`, `buyout_price`, `enable_make_offer`, `make_offer_min`, `make_offer_max`,
  315. `apply_tax`, `bid_increment`, `start_time`, `end_time`, `duration`, `hpfeat`, `catfeat`, `bold`, `highlighted`,
  316. `private_auction`, `disable_sniping`, `nb_relists`, `auto_relist_sold`, `is_relisted`, `country`, `state`, `address`,
  317. `active`, `approved`, `closed`, `deleted`, `draft`, `nb_clicks`, `postage_settings`, `direct_payment`, `offline_payment`, `created_at`)
  318. SELECT
  319. `auction_id`,
  320. IF(`start_price` = `buyout_price`, 'product', 'auction'),
  321. `name`,
  322. `description`,
  323. `owner_id`,
  324. IF(`list_in` = 'auction', 'site', `list_in`),
  325. `category_id`,
  326. IF(`addl_category_id` > 0, `addl_category_id`, NULL),
  327. `currency`,
  328. IF(`start_price` = `buyout_price`, `quantity`, '1'),
  329. `start_price`,
  330. `reserve_price`,
  331. `buyout_price`,
  332. `is_offer`,
  333. `offer_min`,
  334. `offer_max`,
  335. `apply_tax`,
  336. `bid_increment_amount`,
  337. FROM_UNIXTIME(`start_time`),
  338. FROM_UNIXTIME(`end_time`),
  339. `duration`,
  340. `hpfeat`,
  341. `catfeat`,
  342. `bold`,
  343. `hl`,
  344. `hidden_bidding`,
  345. `disable_sniping`,
  346. `auto_relist_nb`,
  347. `auto_relist_bids`,
  348. `is_relisted_item`,
  349. `country`,
  350. `state`,
  351. `zip_code`,
  352. `active`,
  353. `approved`,
  354. `closed`,
  355. `deleted`,
  356. `is_draft`,
  357. `nb_clicks`,
  358. CONCAT('a:5:{',
  359. 's:14:"pickup_options";s:10:"no_pickups";',
  360. 's:7:"postage";a:2:{',
  361. 's:5:"price";a:1:{i:0;s:', LENGTH(`postage_amount`), ':"', `postage_amount`, '";}',
  362. 's:6:"method";a:1:{i:0;s:', IF(`type_service` != '', LENGTH(`type_service`), '8'), ':"',
  363. IF(`type_service` != '', `type_service`, 'Standard'), '";}}',
  364. 's:11:"item_weight";s:', LENGTH(`item_weight`), ':"', `item_weight`, '";',
  365. 's:9:"insurance";s:', LENGTH(`insurance_amount`), ':"', `insurance_amount`, '";',
  366. 's:16:"shipping_details";s:', LENGTH(`shipping_details`), ':"', `shipping_details`, '";}'
  367. ),
  368. IF(`direct_payment` = '0', '', `direct_payment`),
  369. IF(`payment_methods` = '0', '', `payment_methods`),
  370. FROM_UNIXTIME(`creation_date`)
  371. FROM `{%OLD_PREFIX%}auctions`
  372. WHERE `creation_in_progress` = '0';
  373. ## AUCTIONS MEDIA - UPLOAD IMAGES, VIDEOS AND DOWNLOADS SEPARATELY - [ SHOULD BE OK ]
  374. TRUNCATE TABLE `{%NEW_PREFIX%}listings_media`;
  375. # IMAGES
  376. INSERT INTO `{%NEW_PREFIX%}listings_media`
  377. (`id`, `value`, `type`, `listing_id`, `created_at`)
  378. SELECT
  379. `media_id`,
  380. `media_url`,
  381. 'image',
  382. `auction_id`,
  383. now()
  384. FROM `{%OLD_PREFIX%}auction_media`
  385. WHERE `media_type` = '1' AND `upload_in_progress` = '0';
  386. # VIDEOS / DOWNLOADS
  387. INSERT INTO `{%NEW_PREFIX%}listings_media`
  388. (`id`, `value`, `type`, `listing_id`, `created_at`)
  389. SELECT
  390. `media_id`,
  391. `media_url`,
  392. IF(`media_type` = 2, 'video', 'download'),
  393. `auction_id`,
  394. now()
  395. FROM `{%OLD_PREFIX%}auction_media`
  396. WHERE `media_type` IN ('2', '3') AND `upload_in_progress` = '0' AND `embedded_code` = '';
  397. # EMBEDDED VIDEOS
  398. INSERT INTO `{%NEW_PREFIX%}listings_media`
  399. (`id`, `value`, `type`, `listing_id`, `created_at`)
  400. SELECT
  401. `media_id`,
  402. `embedded_code`,
  403. 'video',
  404. `auction_id`,
  405. now()
  406. FROM `{%OLD_PREFIX%}auction_media`
  407. WHERE `media_type` = '2' AND `upload_in_progress` = '0' AND `embedded_code` != '';
  408. ## AUCTION OFFERS - [ OK - W/O CREATED_AT ]
  409. TRUNCATE TABLE `{%NEW_PREFIX%}offers`;
  410. INSERT INTO `{%NEW_PREFIX%}offers`
  411. (`id`, `listing_id`, `user_id`, `quantity`, `amount`, `status`)
  412. SELECT
  413. `offer_id`,
  414. `auction_id`,
  415. `buyer_id`,
  416. `quantity`,
  417. `amount`,
  418. IF(`accepted` = 1, 'accepted', 'declined')
  419. FROM `{%OLD_PREFIX%}auction_offers`;
  420. ## AUCTION WATCH - [ OK ]
  421. TRUNCATE TABLE `{%NEW_PREFIX%}listings_watch`;
  422. INSERT INTO `{%NEW_PREFIX%}listings_watch`
  423. (`id`, `user_id`, `listing_id`, `created_at`)
  424. SELECT
  425. `id`,
  426. `user_id`,
  427. `auction_id`,
  428. now()
  429. FROM `{%OLD_PREFIX%}auction_watch`;
  430. ## BIDS TABLE - [ OK ]
  431. TRUNCATE TABLE `{%NEW_PREFIX%}bids`;
  432. INSERT INTO `{%NEW_PREFIX%}bids`
  433. (`id`, `listing_id`, `user_id`, `amount`, `maximum_bid`, `outbid`, `created_at`)
  434. SELECT
  435. `bid_id`,
  436. `auction_id`,
  437. `bidder_id`,
  438. `bid_amount`,
  439. `bid_proxy`,
  440. IF(`bid_invalid` = 1, 1, `bid_out`),
  441. FROM_UNIXTIME(`bid_date`)
  442. FROM `{%OLD_PREFIX%}bids`;
  443. ## CUSTOM FIELDS BOXES [ OK ] - multiOptions serialized data is converted through code
  444. TRUNCATE TABLE `{%NEW_PREFIX%}custom_fields`;
  445. INSERT INTO `{%NEW_PREFIX%}custom_fields`
  446. (`id`, `type`, `element`, `active`, `order_id`, `category_ids`, `label`, `attributes`, `description`, `multiOptions`, `required`, `searchable`)
  447. SELECT
  448. `b`.`box_id`,
  449. IF(`f`.`page_handle` = 'auction', 'item', 'user'),
  450. IF(`t`.`box_type` = 'list', 'select', `t`.`box_type`),
  451. `f`.`active`,
  452. `f`.`field_order`,
  453. IF(`f`.`category_id` > 0, CONCAT('a:1:{i:0;s:', LENGTH(`f`.`category_id`), ':"', `f`.`category_id`, '";}'), ''),
  454. CONCAT(`f`.`field_name`, ' ', `b`.`box_name`),
  455. 'a:2:{s:3:"key";a:2:{i:0;s:5:"class";i:1;s:0:"";}s:5:"value";a:2:{i:0;s:25:"form-control input-medium";i:1;s:0:"";}}',
  456. `f`.`field_description`,
  457. `b`.`box_value`,
  458. `b`.`mandatory`,
  459. `b`.`box_searchable`
  460. FROM `{%OLD_PREFIX%}custom_fields_boxes` AS `b`
  461. LEFT JOIN `{%OLD_PREFIX%}custom_fields_types` AS `t` ON `t`.`type_id` = `b`.`box_type`
  462. LEFT JOIN `{%OLD_PREFIX%}custom_fields` AS `f` ON `f`.`field_id` = `b`.`field_id`
  463. WHERE `f`.`page_handle` IN ('auction', 'register');
  464. ## CUSTOM FIELDS DATA [ OK ]
  465. TRUNCATE TABLE `{%NEW_PREFIX%}custom_fields_data`;
  466. INSERT INTO `{%NEW_PREFIX%}custom_fields_data`
  467. (`field_id`, `owner_id`, `type`, `value`)
  468. SELECT
  469. `box_id`,
  470. `owner_id`,
  471. IF(`page_handle` = 'auction', 'item', 'user'),
  472. `box_value`
  473. FROM `{%OLD_PREFIX%}custom_fields_data`
  474. WHERE `page_handle` IN ('auction', 'register');
  475. ## FEES
  476. TRUNCATE TABLE `{%NEW_PREFIX%}fees`;
  477. INSERT INTO `{%NEW_PREFIX%}fees`
  478. (`name`, `amount`) VALUES
  479. ('signup', (SELECT
  480. `signup_fee`
  481. FROM `{%OLD_PREFIX%}fees`
  482. WHERE `category_id` = '0'
  483. LIMIT 1));
  484. INSERT INTO `{%NEW_PREFIX%}fees`
  485. (`name`, `amount`) VALUES
  486. ('images', (SELECT
  487. `picture_fee`
  488. FROM `{%OLD_PREFIX%}fees`
  489. WHERE `category_id` = '0'
  490. LIMIT 1));
  491. INSERT INTO `{%NEW_PREFIX%}fees`
  492. (`name`, `amount`) VALUES
  493. ('free_images', (SELECT
  494. `free_images`
  495. FROM `{%OLD_PREFIX%}fees`
  496. WHERE `category_id` = '0'
  497. LIMIT 1));
  498. INSERT INTO `{%NEW_PREFIX%}fees`
  499. (`name`, `amount`) VALUES
  500. ('highlighted', (SELECT
  501. `hlitem_fee`
  502. FROM `{%OLD_PREFIX%}fees`
  503. WHERE `category_id` = '0'
  504. LIMIT 1));
  505. INSERT INTO `{%NEW_PREFIX%}fees`
  506. (`name`, `amount`) VALUES
  507. ('hpfeat', (SELECT
  508. `hpfeat_fee`
  509. FROM `{%OLD_PREFIX%}fees`
  510. WHERE `category_id` = '0'
  511. LIMIT 1));
  512. INSERT INTO `{%NEW_PREFIX%}fees`
  513. (`name`, `amount`) VALUES
  514. ('catfeat', (SELECT
  515. `catfeat_fee`
  516. FROM `{%OLD_PREFIX%}fees`
  517. WHERE `category_id` = '0'
  518. LIMIT 1));
  519. INSERT INTO `{%NEW_PREFIX%}fees`
  520. (`name`, `amount`) VALUES
  521. ('media', (SELECT
  522. `video_fee`
  523. FROM `{%OLD_PREFIX%}fees`
  524. WHERE `category_id` = '0'
  525. LIMIT 1));
  526. INSERT INTO `{%NEW_PREFIX%}fees`
  527. (`name`, `amount`) VALUES
  528. ('free_media', (SELECT
  529. `free_media`
  530. FROM `{%OLD_PREFIX%}fees`
  531. WHERE `category_id` = '0'
  532. LIMIT 1));
  533. INSERT INTO `{%NEW_PREFIX%}fees`
  534. (`name`, `amount`) VALUES
  535. ('addl_category', (SELECT
  536. `second_cat_fee`
  537. FROM `{%OLD_PREFIX%}fees`
  538. WHERE `category_id` = '0'
  539. LIMIT 1));
  540. INSERT INTO `{%NEW_PREFIX%}fees`
  541. (`name`, `amount`) VALUES
  542. ('reserve_price', (SELECT
  543. `rp_fee`
  544. FROM `{%OLD_PREFIX%}fees`
  545. WHERE `category_id` = '0'
  546. LIMIT 1));
  547. INSERT INTO `{%NEW_PREFIX%}fees`
  548. (`name`, `amount`) VALUES
  549. ('buyout', (SELECT
  550. `buyout_fee`
  551. FROM `{%OLD_PREFIX%}fees`
  552. WHERE `category_id` = '0'
  553. LIMIT 1));
  554. INSERT INTO `{%NEW_PREFIX%}fees`
  555. (`name`, `amount`) VALUES
  556. ('make_offer_fee', (SELECT
  557. `makeoffer_fee`
  558. FROM `{%OLD_PREFIX%}fees`
  559. WHERE `category_id` = '0'
  560. LIMIT 1));
  561. INSERT INTO `{%NEW_PREFIX%}fees`
  562. (`name`, `amount`) VALUES
  563. ('digital_downloads_fee', (SELECT
  564. `dd_fee`
  565. FROM `{%OLD_PREFIX%}fees`
  566. WHERE `category_id` = '0'
  567. LIMIT 1));
  568. ## FEES TIERS
  569. # FEES TIERS > FEES
  570. INSERT INTO `{%NEW_PREFIX%}fees`
  571. (`name`, `amount`, `type`, `category_id`, `tier_from`, `tier_to`)
  572. SELECT
  573. IF(`fee_type` = 'setup', 'setup', 'sale'),
  574. `fee_amount`,
  575. `calc_type`,
  576. IF(`category_id` > 0, `category_id`, NULL),
  577. `fee_from`,
  578. `fee_to`
  579. FROM `{%OLD_PREFIX%}fees_tiers`
  580. WHERE `fee_type` IN ('setup', 'endauction');
  581. # FEES TIERS > STORE SUBSCRIPTIONS
  582. TRUNCATE TABLE `{%NEW_PREFIX%}stores_subscriptions`;
  583. INSERT INTO `{%NEW_PREFIX%}stores_subscriptions`
  584. (`id`, `name`, `price`, `listings`, `recurring_days`, `featured_store`)
  585. SELECT
  586. `tier_id`,
  587. `store_name`,
  588. `fee_amount`,
  589. `store_nb_items`,
  590. `store_recurring`,
  591. `store_featured`
  592. FROM `{%OLD_PREFIX%}fees_tiers`
  593. WHERE `fee_type` = 'store';
  594. ## GEN SETTS - [ OK > admin will need to review settings before completing the installation ]
  595. UPDATE `{%NEW_PREFIX%}settings`
  596. SET `value` = (SELECT
  597. `sitename`
  598. FROM `{%OLD_PREFIX%}gen_setts`
  599. LIMIT 1)
  600. WHERE `name` = 'sitename';
  601. UPDATE `{%NEW_PREFIX%}settings`
  602. SET `value` = (SELECT
  603. `currency`
  604. FROM `{%OLD_PREFIX%}gen_setts`
  605. LIMIT 1)
  606. WHERE `name` = 'currency';
  607. UPDATE `{%NEW_PREFIX%}settings`
  608. SET `value` = (SELECT
  609. `amount_format`
  610. FROM `{%OLD_PREFIX%}gen_setts`
  611. LIMIT 1)
  612. WHERE `name` = 'currency_format';
  613. UPDATE `{%NEW_PREFIX%}settings`
  614. SET `value` = (SELECT
  615. `amount_digits`
  616. FROM `{%OLD_PREFIX%}gen_setts`
  617. LIMIT 1)
  618. WHERE `name` = 'currency_decimals';
  619. UPDATE `{%NEW_PREFIX%}settings`
  620. SET `value` = (SELECT
  621. `currency_position`
  622. FROM `{%OLD_PREFIX%}gen_setts`
  623. LIMIT 1)
  624. WHERE `name` = 'currency_position';
  625. UPDATE `{%NEW_PREFIX%}settings`
  626. SET `value` = (SELECT
  627. `max_images`
  628. FROM `{%OLD_PREFIX%}gen_setts`
  629. LIMIT 1)
  630. WHERE `name` = 'images_max';
  631. UPDATE `{%NEW_PREFIX%}settings`
  632. SET `value` = (SELECT
  633. `images_max_size`
  634. FROM `{%OLD_PREFIX%}gen_setts`
  635. LIMIT 1)
  636. WHERE `name` = 'images_size';
  637. UPDATE `{%NEW_PREFIX%}settings`
  638. SET `value` = IF((SELECT
  639. `account_mode`
  640. FROM `{%OLD_PREFIX%}gen_setts`
  641. LIMIT 1) = 1, 'live', 'account')
  642. WHERE `name` = 'payment_mode';
  643. UPDATE `{%NEW_PREFIX%}settings`
  644. SET `value` = (SELECT
  645. `max_credit`
  646. FROM `{%OLD_PREFIX%}gen_setts`
  647. LIMIT 1)
  648. WHERE `name` = 'maximum_debit';
  649. UPDATE `{%NEW_PREFIX%}settings`
  650. SET `value` = (SELECT
  651. `init_credit`
  652. FROM `{%OLD_PREFIX%}gen_setts`
  653. LIMIT 1)
  654. WHERE `name` = 'signup_credit';
  655. UPDATE `{%NEW_PREFIX%}settings`
  656. SET `value` = (SELECT
  657. `enable_private_site`
  658. FROM `{%OLD_PREFIX%}gen_setts`
  659. LIMIT 1)
  660. WHERE `name` = 'private_site';
  661. UPDATE `{%NEW_PREFIX%}settings`
  662. SET `value` = (SELECT
  663. `enable_pref_sellers`
  664. FROM `{%OLD_PREFIX%}gen_setts`
  665. LIMIT 1)
  666. WHERE `name` = 'preferred_sellers';
  667. UPDATE `{%NEW_PREFIX%}settings`
  668. SET `value` = (SELECT
  669. `pref_sellers_reduction`
  670. FROM `{%OLD_PREFIX%}gen_setts`
  671. LIMIT 1)
  672. WHERE `name` = 'preferred_sellers_reduction';
  673. UPDATE `{%NEW_PREFIX%}settings`
  674. SET `value` = (SELECT
  675. `preferred_days`
  676. FROM `{%OLD_PREFIX%}gen_setts`
  677. LIMIT 1)
  678. WHERE `name` = 'preferred_sellers_expiration';
  679. UPDATE `{%NEW_PREFIX%}settings`
  680. SET `value` = (SELECT
  681. `invoice_header`
  682. FROM `{%OLD_PREFIX%}gen_setts`
  683. LIMIT 1)
  684. WHERE `name` = 'invoice_header';
  685. UPDATE `{%NEW_PREFIX%}settings`
  686. SET `value` = (SELECT
  687. `invoice_footer`
  688. FROM `{%OLD_PREFIX%}gen_setts`
  689. LIMIT 1)
  690. WHERE `name` = 'invoice_footer';
  691. UPDATE `{%NEW_PREFIX%}settings`
  692. SET `value` = (SELECT
  693. `enable_stores`
  694. FROM `{%OLD_PREFIX%}gen_setts`
  695. LIMIT 1)
  696. WHERE `name` = 'enable_stores';
  697. UPDATE `{%NEW_PREFIX%}settings`
  698. SET `value` = IF((SELECT
  699. `account_mode_personal`
  700. FROM `{%OLD_PREFIX%}gen_setts`
  701. LIMIT 1) = 1, 'personal', 'global')
  702. WHERE `name` = 'user_account_type';
  703. UPDATE `{%NEW_PREFIX%}settings`
  704. SET `value` = (SELECT
  705. `enable_auctions_approval`
  706. FROM `{%OLD_PREFIX%}gen_setts`
  707. LIMIT 1)
  708. WHERE `name` = 'enable_listings_approval';
  709. UPDATE `{%NEW_PREFIX%}settings`
  710. SET `value` = (SELECT
  711. `signup_settings`
  712. FROM `{%OLD_PREFIX%}gen_setts`
  713. LIMIT 1)
  714. WHERE `name` = 'signup_settings';
  715. UPDATE `{%NEW_PREFIX%}settings`
  716. SET `value` = (SELECT
  717. `makeoffer_process`
  718. FROM `{%OLD_PREFIX%}gen_setts`
  719. LIMIT 1)
  720. WHERE `name` = 'enable_make_offer';
  721. UPDATE `{%NEW_PREFIX%}settings`
  722. SET `value` = (SELECT
  723. `makeoffer_private`
  724. FROM `{%OLD_PREFIX%}gen_setts`
  725. LIMIT 1)
  726. WHERE `name` = 'show_make_offer_ranges';
  727. UPDATE `{%NEW_PREFIX%}settings`
  728. SET `value` = (SELECT
  729. `enable_seller_verification`
  730. FROM `{%OLD_PREFIX%}gen_setts`
  731. LIMIT 1)
  732. WHERE `name` = 'user_verification';
  733. UPDATE `{%NEW_PREFIX%}settings`
  734. SET `value` = (SELECT
  735. `seller_verification_mandatory`
  736. FROM `{%OLD_PREFIX%}gen_setts`
  737. LIMIT 1)
  738. WHERE `name` = 'seller_verification_mandatory';
  739. UPDATE `{%NEW_PREFIX%}settings`
  740. SET `value` = (SELECT
  741. `bidder_verification_mandatory`
  742. FROM `{%OLD_PREFIX%}gen_setts`
  743. LIMIT 1)
  744. WHERE `name` = 'buyer_verification_mandatory';
  745. UPDATE `{%NEW_PREFIX%}settings`
  746. SET `value` = (SELECT
  747. `enable_store_only_mode`
  748. FROM `{%OLD_PREFIX%}gen_setts`
  749. LIMIT 1)
  750. WHERE `name` = 'store_only_mode';
  751. UPDATE `{%NEW_PREFIX%}settings`
  752. SET `value` = (SELECT
  753. `enable_auto_relist`
  754. FROM `{%OLD_PREFIX%}gen_setts`
  755. LIMIT 1)
  756. WHERE `name` = 'auto_relist';
  757. UPDATE `{%NEW_PREFIX%}settings`
  758. SET `value` = (SELECT
  759. `ga_code`
  760. FROM `{%OLD_PREFIX%}gen_setts`
  761. LIMIT 1)
  762. WHERE `name` = 'google_analytics_code';
  763. UPDATE `{%NEW_PREFIX%}settings`
  764. SET `value` = (SELECT
  765. `email_admin_title`
  766. FROM `{%OLD_PREFIX%}gen_setts`
  767. LIMIT 1)
  768. WHERE `name` = 'email_admin_title';
  769. UPDATE `{%NEW_PREFIX%}settings`
  770. SET `value` = (SELECT
  771. `hide_empty_stores`
  772. FROM `{%OLD_PREFIX%}gen_setts`
  773. LIMIT 1)
  774. WHERE `name` = 'hide_empty_stores';
  775. ## WINNERS
  776. # sale_data - a:1:{s:8:"currency";s:3:"GBP";} < we need the currency for the sale!!!
  777. # WINNERS >> SALES
  778. # 1.- where invoice id = 0
  779. TRUNCATE TABLE `{%NEW_PREFIX%}sales`;
  780. INSERT INTO `{%NEW_PREFIX%}sales`
  781. (`id`, `buyer_id`, `seller_id`, `flag_payment`, `flag_shipping`, `sale_data`, `postage_amount`, `insurance_amount`,
  782. `tax_rate`, `active`, `email_sent`, `seller_deleted`, `buyer_deleted`, `edit_locked`, `messaging_topic_id`, `created_at`)
  783. SELECT
  784. IF(`invoice_id` > 0, `invoice_id`, `winner_id`),
  785. `buyer_id`,
  786. `seller_id`,
  787. IF(`direct_payment_paid` = '1', '2', `flag_paid`),
  788. `flag_status`,
  789. CONCAT(
  790. 'a:1:{s:8:"currency";s:3:"',
  791. (SELECT
  792. `a`.`currency`
  793. FROM `{%OLD_PREFIX%}auctions` AS `a`
  794. WHERE `a`.`auction_id` = `auction_id`
  795. LIMIT 1), '";}'),
  796. `postage_amount`,
  797. `insurance_amount`,
  798. `tax_rate`,
  799. `active`,
  800. '1',
  801. `s_deleted`,
  802. `b_deleted`,
  803. '1',
  804. `messaging_topic_id`,
  805. FROM_UNIXTIME(`purchase_date`)
  806. FROM `{%OLD_PREFIX%}winners`
  807. WHERE `invoice_id` = 0;
  808. #2. where invoice_id > 0, group by invoice id
  809. INSERT INTO `{%NEW_PREFIX%}sales`
  810. (`id`, `buyer_id`, `seller_id`, `flag_payment`, `flag_shipping`, `sale_data`, `postage_amount`, `insurance_amount`,
  811. `tax_rate`, `active`, `email_sent`, `seller_deleted`, `buyer_deleted`, `edit_locked`, `messaging_topic_id`, `created_at`)
  812. SELECT
  813. IF(`invoice_id` > 0, `invoice_id`, `winner_id`),
  814. `buyer_id`,
  815. `seller_id`,
  816. IF(`direct_payment_paid` = '1', '2', `flag_paid`),
  817. `flag_status`,
  818. CONCAT(
  819. 'a:1:{s:8:"currency";s:3:"',
  820. (SELECT
  821. `a`.`currency`
  822. FROM `{%OLD_PREFIX%}auctions` AS `a`
  823. WHERE `a`.`auction_id` = `auction_id`
  824. LIMIT 1), '";}'),
  825. `postage_amount`,
  826. `insurance_amount`,
  827. `tax_rate`,
  828. `active`,
  829. '1',
  830. `s_deleted`,
  831. `b_deleted`,
  832. '1',
  833. `messaging_topic_id`,
  834. FROM_UNIXTIME(`purchase_date`)
  835. FROM `{%OLD_PREFIX%}winners`
  836. WHERE `invoice_id` > 0
  837. GROUP BY `invoice_id`;
  838. # WINNERS >> SALES_LISTINGS
  839. TRUNCATE TABLE `{%NEW_PREFIX%}sales_listings`;
  840. INSERT INTO `{%NEW_PREFIX%}sales_listings`
  841. (`id`, `listing_id`, `sale_id`, `price`, `quantity`, `downloads_active`, `created_at`)
  842. SELECT
  843. `winner_id`,
  844. `auction_id`,
  845. IF(`invoice_id` > 0, `invoice_id`, `winner_id`),
  846. `bid_amount`,
  847. `quantity_offered`,
  848. `dd_active`,
  849. FROM_UNIXTIME(`purchase_date`)
  850. FROM `{%OLD_PREFIX%}winners`;
  851. ## ACCOUNTING TABLE - [ OK ]
  852. TRUNCATE TABLE `{%NEW_PREFIX%}accounting`;
  853. # INVOICES >> ACCOUNTING
  854. INSERT INTO `{%NEW_PREFIX%}accounting`
  855. (`name`, `amount`, `tax_rate`, `currency`, `user_id`, `listing_id`, `created_at`)
  856. SELECT
  857. `name`,
  858. `amount`,
  859. `tax_rate`,
  860. @default_currency,
  861. `user_id`,
  862. IF(`item_id` > 0, `item_id`, NULL),
  863. FROM_UNIXTIME(`invoice_date`)
  864. FROM `{%OLD_PREFIX%}invoices`
  865. WHERE `user_id` > 0 AND `live_fee` = 0;
  866. # INVOICES >> TRANSACTIONS
  867. TRUNCATE TABLE `{%NEW_PREFIX%}transactions`;
  868. INSERT INTO `{%NEW_PREFIX%}transactions`
  869. (`name`, `amount`, `tax_rate`, `currency`, `user_id`, `paid`, `gateway_transaction_code`, `created_at`)
  870. SELECT
  871. `name`,
  872. `amount`,
  873. `tax_rate`,
  874. @default_currency,
  875. `user_id`,
  876. '1',
  877. CONCAT('[OLD]', `processor`),
  878. FROM_UNIXTIME(`invoice_date`)
  879. FROM `{%OLD_PREFIX%}invoices`
  880. WHERE `live_fee` = 1;
  881. ## MESSAGING - [ OK ]
  882. TRUNCATE TABLE `{%NEW_PREFIX%}messaging`;
  883. INSERT INTO `{%NEW_PREFIX%}messaging`
  884. (`id`, `topic_id`, `title`, `content`, `sender_id`, `receiver_id`, `listing_id`, `sale_id`, `flag_read`,
  885. `sender_deleted`, `receiver_deleted`, `created_at`)
  886. SELECT
  887. `message_id`,
  888. `topic_id`,
  889. `message_title`,
  890. `message_content`,
  891. `sender_id`,
  892. `receiver_id`,
  893. IF((`message_handle` = 1 AND `auction_id` > 0), `auction_id`, NULL),
  894. IF(`winner_id` > 0, `winner_id`, NULL),
  895. `is_read`,
  896. `sender_deleted`,
  897. `receiver_deleted`,
  898. FROM_UNIXTIME(`reg_date`)
  899. FROM `{%OLD_PREFIX%}messaging`;
  900. ## PAYMENT OPTIONS - [ OK ]
  901. TRUNCATE TABLE `{%NEW_PREFIX%}offline_payment_methods`;
  902. INSERT INTO `{%NEW_PREFIX%}offline_payment_methods`
  903. (`id`, `name`, `logo`)
  904. SELECT
  905. `id`,
  906. `name`,
  907. `logo_url`
  908. FROM `{%OLD_PREFIX%}payment_options`;
  909. ## REPUTATION - winner_id = sale_listing_id - [ OK - reputation_type ~ ]
  910. TRUNCATE TABLE `{%NEW_PREFIX%}reputation`;
  911. INSERT INTO `{%NEW_PREFIX%}reputation`
  912. (`id`, `user_id`, `poster_id`, `sale_listing_id`, `score`, `comments`, `reputation_type`,
  913. `posted`, `created_at`)
  914. SELECT
  915. `reputation_id`,
  916. `user_id`,
  917. `from_id`,
  918. `winner_id`,
  919. `reputation_rate`,
  920. `reputation_content`,
  921. `reputation_type`,
  922. `submitted`,
  923. FROM_UNIXTIME(`reg_date`)
  924. FROM `{%OLD_PREFIX%}reputation`;
  925. ## ENABLE FOREIGN KEY CHECKS
  926. SET foreign_key_checks = 1;